public function invalidate(AbstractTerritoire $territoire)
 {
     $timestamp = $this->em->getRepository('AppBundle\\Repository\\CacheInfo\\TerritoireTimestamp')->findOneByTerritoire($territoire);
     if (!$timestamp && $this->toPersist->offsetExists($territoire)) {
         $timestamp = $this->toPersist[$territoire];
     }
     if ($timestamp) {
         $timestamp->setNow();
     }
     if (!$timestamp) {
         $timestamp = new TerritoireTimestamp($territoire);
         $this->em->persist($timestamp);
         $this->toPersist[$territoire] = $timestamp;
     }
     if ($territoire instanceof Commune) {
         $this->invalidate($territoire->getDepartement());
         return;
     }
     if ($territoire instanceof Departement) {
         $this->invalidate($territoire->getRegion());
         return;
     }
     if ($territoire instanceof Region && $territoire->getCirconscriptionEuropeenne()) {
         $this->invalidate($territoire->getCirconscriptionEuropeenne());
     }
     if ($territoire instanceof Region || $territoire instanceof CirconscriptionEuropeenne) {
         $this->invalidate($territoire->getPays());
     }
 }
 /**
  * @param Property $property
  * @return AggregatorRelay
  * @throws UnexpectedValueException
  */
 public function getByProperty(Property $property)
 {
     if (!$this->map->offsetExists($property)) {
         throw new UnexpectedValueException();
     }
     return $this->map->offsetGet($property);
 }
 /**
  * @param $helper
  *
  * @throws \AGmakonts\DddBricks\Repository\Exception\HelperException
  */
 private function setHelper(AbstractRepository $helper)
 {
     if (get_called_class() === $helper) {
         throw new HelperException(HelperException::HELPER_SELF_REFERENCING);
     }
     if (TRUE === $this->_helpers->offsetExists($helper->getEntityType())) {
         throw new HelperException(HelperException::HELPER_ALREADY_REQUESTED);
     }
     $this->_helpers->attach($helper->getEntityType(), $helper);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function executeCommand(CommandInterface $command)
 {
     $this->storeCommand($command);
     $this->performExecution(function () use($command) {
         $priority = $command->getPriority();
         while (!empty($this->commands) && $this->commands[0]->getPriority() >= $priority) {
             $cmd = array_shift($this->commands);
             $this->commandResults[$cmd] = $cmd->execute($this);
             $this->executionCount++;
             if ($cmd === $command) {
                 // Bail out as soon as target command has been executed.
                 break;
             }
         }
         if ($this->executionDepth == 1) {
             // Execute remaining commands if this is a top level execution.
             while (!empty($this->commands)) {
                 $cmd = array_shift($this->commands);
                 $this->commandResults[$cmd] = $cmd->execute($this);
                 $this->executionCount++;
             }
         }
     });
     try {
         if ($this->commandResults->offsetExists($command)) {
             return $this->commandResults[$command];
         }
     } finally {
         if ($this->executionDepth == 0) {
             // Free command result memory after top level execution.
             $this->commandResults = new \SplObjectStorage();
         }
     }
 }
示例#5
0
 /**
  * Whether a offset exists
  * @link http://php.net/manual/en/arrayaccess.offsetexists.php
  * @param mixed $offset <p>
  * An offset to check for.
  * </p>
  * @return boolean true on success or false on failure.
  * </p>
  * <p>
  * The return value will be casted to boolean if non-boolean was returned.
  * @since 5.0.0
  */
 public function offsetExists($offset)
 {
     if (is_scalar($offset)) {
         return array_key_exists($offset, $this->scalarStore);
     }
     if (is_object($offset)) {
         return $this->objectStore->offsetExists($offset);
     }
     if (is_array($offset)) {
         foreach ($this->arrayKeys as $index => $entry) {
             if ($entry === $offset) {
                 $this->lastArrayKey = $offset;
                 $this->lastArrayValue = $this->arrayValues[$index];
                 return true;
             }
         }
     }
     return false;
 }
示例#6
0
文件: core.php 项目: jerfowler/yada
 public function link($model = NULL, $field = NULL, $reverse = FALSE)
 {
     var_dump('Link');
     if (!$model instanceof Yada_Model) {
         $field = $model;
         $model = $this->_model;
     }
     var_dump($field->name);
     $this->field($model, $field);
     $field = $this->_field;
     if (!$field instanceof Yada_Field_Interface_Related) {
         throw new Kohana_Exception('Field :name in Model :model isn\'t a Related Field', array(':name' => $field->name, ':model' => Yada::common_name('model', $model)));
     }
     $related = $field->related();
     if (!$this->_linked->offsetExists($field)) {
         $this->_linked[$field] = array($related, $reverse);
         $related->mapper->link($related->model, $related, TRUE);
     }
     return $related->model;
 }
示例#7
0
 public function offsetUnset($index)
 {
     $this->validateIndex($index);
     // Decrement counters when replacing existing item
     if (parent::offsetExists($index)) {
         $oldResult = parent::offsetGet($index);
         if ($oldResult instanceof Success) {
             $this->countSuccess--;
         } elseif ($oldResult instanceof Failure) {
             $this->countFailure--;
         } elseif ($oldResult instanceof Warning) {
             $this->countWarning--;
         } else {
             $this->countUnknown--;
         }
     }
     parent::offsetUnset($index);
 }
 public function offsetExists($object)
 {
     $this->initialize();
     return parent::offsetExists($object);
 }
示例#9
0
文件: Crawler.php 项目: 0mars/symfony
 /**
  * @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
  */
 public function offsetExists($object)
 {
     @trigger_error('The ' . __METHOD__ . ' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
     return parent::offsetExists($object);
 }
示例#10
0
 /**
  * @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
  */
 public function offsetExists($object)
 {
     $this->triggerDeprecation(__METHOD__);
     return parent::offsetExists($object);
 }
示例#11
0
 /**
  * @param object $index
  * @link http://php.net/manual/en/splobjectstorage.offsetunset.php
  */
 public function offsetUnset($index)
 {
     $this->validateIndex($index);
     // Decrement counters when replacing existing item
     if (parent::offsetExists($index)) {
         $this->updateCounters(parent::offsetGet($index), -1);
     }
     parent::offsetUnset($index);
 }
 private function isSubscribed(WebSocketConnection $connection)
 {
     return $this->connectionTableMap->offsetExists($connection);
 }
示例#13
0
$obj->setInfo('AAA');
// getInfo()
// 获得当前节点的值。也必须是调用rewind后,才可以调用getInfo。
$obj->getInfo();
// current()
// 获得当前节点对象
$obj->current();
// getHash()
// 获得参数的hash值
$obj->getHash($a2);
// next()
// 指针移到下一个节点
$obj->next();
// offsetExists
// 判断对象容器中是否存在该对象
$obj->offsetExists($a2);
// offsetSet()
// 给对象容器中的某个对象设置值
$obj->offsetSet($a2, 'BBB');
// offsetGet()
// 获得对象容器中的某个针对象对应的值
$obj->offsetGet($a2);
// offsetUnset()
// 将某节点删除
//$obj->offsetUnset($a1);
// serialize()
// 将对象容器序列化
$serialize_obj = $obj->serialize();
// unserialize()
// 将对象容器反序列化
$obj_2 = new SplObjectStorage();
示例#14
0
 /**
  * @param object $offset
  * @return bool
  */
 public function offsetExists($offset)
 {
     return $this->list->offsetExists($offset);
 }
 /**
  * return true if the payment should not be processed
  *
  * @param  Mage_Sales_Model_Order_Payment $payment
  * @param  SplObjectStorage               $processedPayments
  * @return bool
  */
 protected function _shouldIgnorePayment(Mage_Sales_Model_Order_Payment $payment, SplObjectStorage $processedPayments)
 {
     return $processedPayments->offsetExists($payment) || $payment->getMethod() === Mage::getModel('payment/method_free')->getCode();
 }
示例#16
0
 /**
  * Creates and returns list of all file attributes validators.
  * @return Validator[] list validators.
  * @throws InvalidValueException if the behavior has invalid owner.
  */
 public function createValidators()
 {
     if (!($owner = $this->owner) || !$owner instanceof Model) {
         throw new InvalidValueException(get_class($this) . ' must be attached to an instance of ' . Model::className() . '.');
     }
     $contexts = new \SplObjectStorage();
     foreach ($this->fileAttributes() as $fileAttribute) {
         $context = $this->getFileContext($fileAttribute);
         $fileAttributes = $contexts->offsetExists($context) ? $contexts->offsetGet($context) : [];
         $fileAttributes[] = $fileAttribute;
         $contexts->offsetSet($context, $fileAttributes);
     }
     $result = [];
     $contexts->rewind();
     while ($contexts->valid()) {
         $context = $contexts->current();
         $fileAttributes = $contexts->getInfo();
         foreach ($context->getValidators() as $validator) {
             $validator = Validator::createValidator($validator[0], $owner, $fileAttributes, array_slice($validator, 1, null, true));
             $result[] = $validator;
         }
         $contexts->next();
     }
     return $result;
 }