/** * @param CategoryModel $category * @depends testCreate */ public function testUpdate(CategoryModel $category) { $template = new Template(); $template->setName('A sample template')->save(); $event = new CategoryUpdateEvent($category->getId()); $event->setLocale('en_US')->setTitle('bar')->setDescription('bar description')->setChapo('bar chapo')->setPostscriptum('bar postscriptum')->setVisible(0)->setParent(0)->setDefaultTemplateId($template->getId())->setDispatcher($this->getDispatcher()); $action = new Category(); $action->update($event); $updatedCategory = $event->getCategory(); $this->assertInstanceOf('Thelia\\Model\\Category', $updatedCategory); $this->assertEquals('en_US', $updatedCategory->getLocale()); $this->assertEquals('bar', $updatedCategory->getTitle()); $this->assertEquals('bar description', $updatedCategory->getDescription()); $this->assertEquals('bar chapo', $updatedCategory->getChapo()); $this->assertEquals('bar postscriptum', $updatedCategory->getPostscriptum()); $this->assertEquals(0, $updatedCategory->getVisible()); $this->assertEquals($template->getId(), $updatedCategory->getDefaultTemplateId()); $this->assertEquals(0, $updatedCategory->getParent()); return [$updatedCategory, $template]; }
/** * Create a new template entry * * @param \Thelia\Core\Event\Template\TemplateCreateEvent $event */ public function create(TemplateCreateEvent $event) { $template = new TemplateModel(); $template->setDispatcher($event->getDispatcher())->setLocale($event->getLocale())->setName($event->getTemplateName())->save(); $event->setTemplate($template); }
/** * Declares an association between this object and a ChildTemplate object. * * @param ChildTemplate $v * @return \Thelia\Model\Product The current object (for fluent API support) * @throws PropelException */ public function setTemplate(ChildTemplate $v = null) { if ($v === null) { $this->setTemplateId(NULL); } else { $this->setTemplateId($v->getId()); } $this->aTemplate = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildTemplate object, it will not be re-added. if ($v !== null) { $v->addProduct($this); } return $this; }
/** * Filter the query by a related \Thelia\Model\Template object * * @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductQuery The current query, for fluid interface */ public function filterByTemplate($template, $comparison = null) { if ($template instanceof \Thelia\Model\Template) { return $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $template->getId(), $comparison); } elseif ($template instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(ProductTableMap::TEMPLATE_ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByTemplate() only accepts arguments of type \\Thelia\\Model\\Template or Collection'); } }
/** * Exclude object from result * * @param ChildTemplate $template Object to remove from the list of results * * @return ChildTemplateQuery The current query, for fluid interface */ public function prune($template = null) { if ($template) { $this->addUsingAlias(TemplateTableMap::ID, $template->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Create a new template entry * * @param \Thelia\Core\Event\Template\TemplateCreateEvent $event * @param $eventName * @param EventDispatcherInterface $dispatcher */ public function create(TemplateCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $template = new TemplateModel(); $template->setDispatcher($dispatcher)->setLocale($event->getLocale())->setName($event->getTemplateName())->save(); $event->setTemplate($template); }
/** * @param Template $object * @return int */ protected function getObjectId($object) { return $object->getId(); }