Example #1
0
 /**
  * @param AttributeModel $attribute
  * @depends testUpdate
  */
 public function testDelete(AttributeModel $attribute)
 {
     $event = new AttributeDeleteEvent($attribute->getId());
     $action = new Attribute();
     $action->delete($event, null, $this->getMockEventDispatcher());
     $deletedAttribute = $event->getAttribute();
     $this->assertInstanceOf('Thelia\\Model\\Attribute', $deletedAttribute);
     $this->assertTrue($deletedAttribute->isDeleted());
 }
Example #2
0
 /**
  * @depends testUpdate
  */
 public function testDelete(AttributeModel $attribute)
 {
     $event = new AttributeDeleteEvent($attribute->getId());
     $event->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface"));
     $action = new Attribute();
     $action->delete($event);
     $deletedAttribute = $event->getAttribute();
     $this->assertInstanceOf('Thelia\\Model\\Attribute', $deletedAttribute);
     $this->assertTrue($deletedAttribute->isDeleted());
 }
Example #3
0
 /**
  * Create a new attribute entry
  *
  * @param AttributeCreateEvent $event
  */
 public function create(AttributeCreateEvent $event)
 {
     $attribute = new AttributeModel();
     $attribute->setDispatcher($event->getDispatcher())->setLocale($event->getLocale())->setTitle($event->getTitle())->save();
     $event->setAttribute($attribute);
     // Add atribute to all product templates if required
     if ($event->getAddToAllTemplates() != 0) {
         $this->doAddToAllTemplates($attribute);
     }
 }
Example #4
0
 /**
  * Declares an association between this object and a ChildAttribute object.
  *
  * @param                  ChildAttribute $v
  * @return                 \Thelia\Model\AttributeI18n The current object (for fluent API support)
  * @throws PropelException
  */
 public function setAttribute(ChildAttribute $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aAttribute = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildAttribute object, it will not be re-added.
     if ($v !== null) {
         $v->addAttributeI18n($this);
     }
     return $this;
 }
 /**
  * Filter the query by a related \Thelia\Model\Attribute object
  *
  * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildAttributeTemplateQuery The current query, for fluid interface
  */
 public function filterByAttribute($attribute, $comparison = null)
 {
     if ($attribute instanceof \Thelia\Model\Attribute) {
         return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
     } elseif ($attribute instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByAttribute() only accepts arguments of type \\Thelia\\Model\\Attribute or Collection');
     }
 }
Example #6
0
 /**
  * Exclude object from result
  *
  * @param   ChildAttribute $attribute Object to remove from the list of results
  *
  * @return ChildAttributeQuery The current query, for fluid interface
  */
 public function prune($attribute = null)
 {
     if ($attribute) {
         $this->addUsingAlias(AttributeTableMap::ID, $attribute->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * @param Attribute $object
  * @return int
  */
 protected function getObjectId($object)
 {
     return $object->getId();
 }