Пример #1
0
 protected function addResource($code)
 {
     if (null === ResourceQuery::create()->findOneByCode($code)) {
         $resource = new Resource();
         $resource->setCode($code);
         $resource->setTitle($code);
         $resource->save();
     }
 }
Пример #2
0
 /**
  * Declares an association between this object and a ChildResource object.
  *
  * @param                  ChildResource $v
  * @return                 \Thelia\Model\ProfileResource The current object (for fluent API support)
  * @throws PropelException
  */
 public function setResource(ChildResource $v = null)
 {
     if ($v === null) {
         $this->setResourceId(NULL);
     } else {
         $this->setResourceId($v->getId());
     }
     $this->aResource = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildResource object, it will not be re-added.
     if ($v !== null) {
         $v->addProfileResource($this);
     }
     return $this;
 }
Пример #3
0
 /**
  * Filter the query by a related \Thelia\Model\Resource object
  *
  * @param \Thelia\Model\Resource|ObjectCollection $resource The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildResourceI18nQuery The current query, for fluid interface
  */
 public function filterByResource($resource, $comparison = null)
 {
     if ($resource instanceof \Thelia\Model\Resource) {
         return $this->addUsingAlias(ResourceI18nTableMap::ID, $resource->getId(), $comparison);
     } elseif ($resource instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ResourceI18nTableMap::ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByResource() only accepts arguments of type \\Thelia\\Model\\Resource or Collection');
     }
 }
Пример #4
0
 /**
  * Exclude object from result
  *
  * @param   ChildResource $resource Object to remove from the list of results
  *
  * @return ChildResourceQuery The current query, for fluid interface
  */
 public function prune($resource = null)
 {
     if ($resource) {
         $this->addUsingAlias(ResourceTableMap::ID, $resource->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }