forked from marellocommerce/marello
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature/MAR10001-345-order-api
- Loading branch information
Showing
186 changed files
with
5,334 additions
and
1,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/Marello/Bundle/CatalogBundle/Controller/CategoryController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\CatalogBundle\Controller; | ||
|
||
use Marello\Bundle\CatalogBundle\Entity\Category; | ||
use Oro\Bundle\SecurityBundle\Annotation as Security; | ||
use Oro\Bundle\UIBundle\Route\Router; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
class CategoryController extends Controller | ||
{ | ||
/** | ||
* @Config\Route( | ||
* "/{_format}", | ||
* name="marello_category_index", | ||
* requirements={"_format"="html|json"}, | ||
* defaults={"_format"="html"} | ||
* ) | ||
* @Security\AclAncestor("marello_category_view") | ||
* @Config\Template | ||
*/ | ||
public function indexAction() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @Config\Route("/create", name="marello_category_create") | ||
* @Security\AclAncestor("marello_category_create") | ||
* @Config\Template("MarelloCatalogBundle:Category:update.html.twig") | ||
* | ||
* @return array | ||
*/ | ||
public function createAction() | ||
{ | ||
return $this->update(new Category()); | ||
} | ||
|
||
/** | ||
* @Config\Route("/update/{id}", requirements={"id"="\d+"}, name="marello_category_update") | ||
* @Security\AclAncestor("marello_category_update") | ||
* @Config\Template("MarelloCatalogBundle:Category:update.html.twig") | ||
* | ||
* @param Category $category | ||
* | ||
* @return array | ||
*/ | ||
public function updateAction(Category $category) | ||
{ | ||
return $this->update($category); | ||
} | ||
|
||
/** | ||
* @param Category $category | ||
* | ||
* @return array | ||
*/ | ||
protected function update(Category $category) | ||
{ | ||
$handler = $this->get('marello_catalog.category.form.handler'); | ||
|
||
if ($handler->process($category)) { | ||
$this->get('session')->getFlashBag()->add( | ||
'success', | ||
$this->get('translator')->trans('marello.catalog.ui.category.saved.message') | ||
); | ||
|
||
return $this->get('oro_ui.router')->redirect($category); | ||
} | ||
|
||
return [ | ||
'entity' => $category, | ||
'form' => $handler->getFormView(), | ||
]; | ||
} | ||
|
||
/** | ||
* @Config\Route("/view/{id}", requirements={"id"="\d+"}, name="marello_category_view") | ||
* @Security\AclAncestor("marello_category_view") | ||
* @Config\Template("MarelloCatalogBundle:Category:view.html.twig") | ||
* | ||
* @param Category $category | ||
* | ||
* @return array | ||
*/ | ||
public function viewAction(Category $category) | ||
{ | ||
return [ | ||
'entity' => $category, | ||
]; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Marello/Bundle/CatalogBundle/DependencyInjection/MarelloCatalogExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\CatalogBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
class MarelloCatalogExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(array $config, ContainerBuilder $container) | ||
{ | ||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\CatalogBundle\Entity; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Marello\Bundle\CatalogBundle\Model\ExtendCategory; | ||
use Marello\Bundle\CoreBundle\Model\EntityCreatedUpdatedAtTrait; | ||
use Marello\Bundle\ProductBundle\Entity\Product; | ||
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; | ||
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField; | ||
use Oro\Bundle\OrganizationBundle\Entity\OrganizationAwareInterface; | ||
use Oro\Bundle\OrganizationBundle\Entity\Ownership\AuditableOrganizationAwareTrait; | ||
|
||
/** | ||
* @ORM\Entity() | ||
* @ORM\Table(name="marello_catalog_category") | ||
* @Config( | ||
* routeName="marello_category_index", | ||
* routeView="marello_category_view", | ||
* routeUpdate="marello_category_update", | ||
* defaultValues={ | ||
* "entity"={ | ||
* "icon"="fa-folder" | ||
* }, | ||
* "ownership"={ | ||
* "owner_type"="ORGANIZATION", | ||
* "owner_field_name"="organization", | ||
* "owner_column_name"="organization_id" | ||
* }, | ||
* "security"={ | ||
* "type"="ACL", | ||
* "group_name"="", | ||
* "category"="catalog" | ||
* }, | ||
* "dataaudit"={ | ||
* "auditable"=true | ||
* } | ||
* } | ||
* ) | ||
* @ORM\HasLifecycleCallbacks() | ||
* | ||
* @SuppressWarnings(PHPMD.TooManyPublicMethods) | ||
*/ | ||
class Category extends ExtendCategory implements OrganizationAwareInterface | ||
{ | ||
use EntityCreatedUpdatedAtTrait; | ||
use AuditableOrganizationAwareTrait; | ||
|
||
/** | ||
* @var integer | ||
* | ||
* @ORM\Column(name="id", type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
* @ConfigField( | ||
* defaultValues={ | ||
* "dataaudit"={ | ||
* "auditable"=true | ||
* } | ||
* } | ||
* ) | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", nullable=false) | ||
* @ConfigField( | ||
* defaultValues={ | ||
* "dataaudit"={ | ||
* "auditable"=true | ||
* } | ||
* } | ||
* ) | ||
*/ | ||
protected $code; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(name="description", type="text", nullable=true) | ||
* @ConfigField( | ||
* defaultValues={ | ||
* "dataaudit"={ | ||
* "auditable"=true | ||
* } | ||
* } | ||
* ) | ||
*/ | ||
protected $description; | ||
|
||
/** | ||
* @var Collection|Product[] | ||
* | ||
* @ORM\ManyToMany(targetEntity="Marello\Bundle\ProductBundle\Entity\Product", inversedBy="categories") | ||
* @ORM\JoinTable( | ||
* name="marello_category_to_product", | ||
* joinColumns={ | ||
* @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE") | ||
* }, | ||
* inverseJoinColumns={ | ||
* @ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="CASCADE", unique=true) | ||
* } | ||
* ) | ||
* @ConfigField( | ||
* defaultValues={ | ||
* "dataaudit"={ | ||
* "auditable"=true | ||
* } | ||
* } | ||
* ) | ||
*/ | ||
protected $products; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->products = new ArrayCollection(); | ||
} | ||
|
||
/** | ||
* @return integer | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCode() | ||
{ | ||
return $this->code; | ||
} | ||
|
||
/** | ||
* @param string $code | ||
* @return $this | ||
*/ | ||
public function setCode($code) | ||
{ | ||
$this->code = $code; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDescription() | ||
{ | ||
return $this->description; | ||
} | ||
|
||
/** | ||
* @param string $description | ||
* @return $this | ||
*/ | ||
public function setDescription($description) | ||
{ | ||
$this->description = $description; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return Collection|Product[] | ||
*/ | ||
public function getProducts() | ||
{ | ||
return $this->products; | ||
} | ||
|
||
/** | ||
* @param Product $product | ||
* @return $this | ||
*/ | ||
public function addProduct(Product $product) | ||
{ | ||
if (!$this->hasProduct($product)) { | ||
$this->products->add($product); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param Product $product | ||
* @return $this | ||
*/ | ||
public function removeProduct(Product $product) | ||
{ | ||
if ($this->hasProduct($product)) { | ||
$this->products->removeElement($product); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param Product $product | ||
* @return bool | ||
*/ | ||
public function hasProduct(Product $product) | ||
{ | ||
return $this->products->contains($product); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __toString() | ||
{ | ||
return (string)$this->getName(); | ||
} | ||
} |
Oops, something went wrong.