/**
  * do the magic!
  *
  * @param tx_rnbase_parameters $parameters
  * @param tx_rnbase_configurations $configurations
  * @param ArrayObject $viewData
  *
  * @return string error msg or null
  */
 public function handleRequest(&$parameters, &$configurations, &$viewData)
 {
     $items = $this->getItems();
     $viewData->offsetSet('items', is_array($items) ? array_values($items) : array());
     $viewData->offsetSet('searched', $items !== FALSE);
     return;
 }
 /**
  * Add the result to this result object
  *
  * @param $result
  */
 protected function addResult($result)
 {
     if (!array_key_exists('url', $result) && !array_key_exists('checksum', $result)) {
         return;
     }
     $this->result->offsetSet(md5($result['url']), $result);
 }
Example #3
0
 /**
  * Proccess queue
  *
  * @param int $maxExecutionTime Maximum execution time available
  *
  * @return boolean If all requested items could be processed
  */
 public function processQueue($maxExecutionTime = INF)
 {
     try {
         /* @var $shipment Dhl_Intraship_Model_Mysql4_Shipment_Collection */
         $collection = Mage::getModel('intraship/shipment')->getCollection()->joinOrderTable();
         // Add filter status codes to where clause.
         $collection->addFieldToFilter('main_table.status', array('in' => array(Dhl_Intraship_Model_Shipment::STATUS_NEW_QUEUED, Dhl_Intraship_Model_Shipment::STATUS_NEW_RETRY, Dhl_Intraship_Model_Shipment::STATUS_CANCEL_QUEUED, Dhl_Intraship_Model_Shipment::STATUS_CANCEL_RETRY)));
         // Create shipment for each queue.
         if (0 < count($collection)) {
             $startTime = time();
             $shipmentOffset = 0;
             /* @var $row Dhl_Intraship_Model_Shipment */
             foreach ($collection as $shipment) {
                 ++$shipmentOffset;
                 //Skip shipment if current status has changed to avoid double shipment transmission
                 if (Mage::getModel('intraship/shipment')->load($shipment->getId())->getStatus() != $shipment->getStatus()) {
                     continue;
                 }
                 try {
                     $fallback = new ArrayObject(array());
                     if (!$shipment instanceof Dhl_Intraship_Model_Shipment) {
                         continue;
                     }
                     switch ($shipment->getStatus()) {
                         case Dhl_Intraship_Model_Shipment::STATUS_NEW_QUEUED:
                         case Dhl_Intraship_Model_Shipment::STATUS_NEW_RETRY:
                             $fallback->offsetSet('type', 'create');
                             $fallback->offsetSet('status', Dhl_Intraship_Model_Shipment::STATUS_NEW_FAILED);
                             $this->_create($shipment);
                             break;
                         case Dhl_Intraship_Model_Shipment::STATUS_CANCEL_QUEUED:
                         case Dhl_Intraship_Model_Shipment::STATUS_CANCEL_RETRY:
                             $fallback->offsetSet('type', 'cancel');
                             $fallback->offsetSet('status', Dhl_Intraship_Model_Shipment::STATUS_CANCELED_FAILED);
                             $this->_cancel($shipment);
                             break;
                     }
                 } catch (Exception $e) {
                     Mage::logException($e);
                     $this->logMessage($e->getMessage());
                     $shipment->setStatus($fallback->offsetGet('status'))->setClientStatusCode(1000)->setClientStatusMessage($e->getMessage())->addComment($e->getMessage(), $fallback->offsetGet('status'), $fallback->offsetGet('type'));
                 }
                 if ($shipment->getShipment()->getId() && $shipment->getShipment()->getOrder()->getId()) {
                     // Save comments.
                     $shipment->saveComments();
                     // Save modified shipment.
                     $shipment->save();
                 }
                 // Stop processing 10s before we run out of time
                 if ($shipmentOffset < $collection->count() && $maxExecutionTime - 10 < time() - $startTime) {
                     return false;
                 }
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
         throw new Dhl_Intraship_Model_Soap_Client_Response_Exception($e->getMessage(), $e->getCode());
     }
     return true;
 }
Example #4
0
 /**
  * Adds new route to router.
  *
  * @param $routeName
  * @param array $value
  * @return boolean
  */
 public function addConfigItem($routeName, array $value)
 {
     if (!$this->hasConfigItem($routeName)) {
         $this->config->offsetSet($routeName, $value);
         return true;
     }
     return false;
 }
 /**
  * @param mixed $namespace The namespace or identifier.
  * @param mixed $value     The value.
  *
  * @throws \LogicException If key should be overwritten.
  */
 public static function set($namespace, $value)
 {
     self::init();
     if (is_resource($value)) {
         throw new \LogicException('storing resources in a registry is not permitted!');
     }
     self::$battery->offsetSet($namespace, $value);
 }
Example #6
0
 /**
  * Sets the given options.
  *
  * @param array $options Array of options, keys = option name, value = option value.
  * @param bool $reset If set, the existing options are deleted before the new ones are set.
  */
 public function setOptions(array $options, $reset = false)
 {
     if ($reset || !$this->_options instanceof ArrayObject) {
         $this->_options = new ArrayObject($options);
         return;
     }
     foreach ($options as $key => $value) {
         $this->_options->offsetSet($key, $value);
     }
 }
 /**
  * returns field descriptor
  *
  * @throws \VisioCrudModeler\Exception\FieldNotFound
  * @return DbFieldDescriptor
  */
 public function getFieldDescriptor($fieldName)
 {
     if (!array_key_exists($fieldName, $this->definition['fields'])) {
         throw new FieldNotFound("field '" . $fieldName . "' not found in '" . $this->getName() . "'");
     }
     if (!$this->fieldDescriptors->offsetExists($fieldName)) {
         $this->fieldDescriptors->offsetSet($fieldName, new WebFieldDescriptor($this, $this->definition['fields'][$fieldName]));
     }
     return $this->fieldDescriptors->offsetGet($fieldName);
 }
Example #8
0
 /**
  * Process the registration of one service.
  *
  * @param string $className The class name of the service
  *
  * @throws \Subbly\Api\Exception If class name does not exists
  * @throws \Subbly\Api\Exception If the class does not implement \Subbly\Api\Service\Service
  * @throws \Subbly\Api\Exception If service name is already register
  */
 public function registerService($className)
 {
     if (!class_exists($className)) {
         throw new Exception(sprintf(Exception::SERVICE_CLASS_NOT_EXISTS, $className));
     }
     $service = new $className($this);
     if (!$service instanceof Service) {
         throw new Exception(sprintf(Exception::NOT_A_SERVICE, $className));
     }
     if ($this->services->offsetExists($service->name())) {
         throw new Exception(sprintf(Exception::SERVICE_ALREADY_EXISTS, $service->name()));
     }
     $this->services->offsetSet($service->name(), $service);
 }
 /**
  * Return a synthetic table
  *
  * @param string $table_name table name
  *
  * @throws Exception\InvalidArgumentException if table name is not valid
  *
  * @return Table
  */
 public function table($table_name)
 {
     if (!is_string($table_name)) {
         throw new Exception\InvalidArgumentException(__METHOD__ . ": Table name must be a string");
     }
     if (!$this->localTableCache->offsetExists($table_name)) {
         $tables = $this->metadata()->getTables();
         if (!in_array($table_name, $tables)) {
             throw new Exception\TableNotFoundException(__METHOD__ . ": Table {$table_name} is not found in database, if table exists please make sure cache is updated.");
         }
         $table = new Table($table_name, $this);
         $this->localTableCache->offsetSet($table_name, $table);
     }
     return $this->localTableCache->offsetGet($table_name);
 }
Example #10
0
 public function buildListPage()
 {
     if ($this->nbElement > $this->limit) {
         for ($pas = 1, $index = 1; $pas <= $this->nbElement; $pas += $this->limit, $index++) {
             $page = new Page($index, $this->router, $this->route, $this->routeParam);
             if ((int) $this->offset === (int) $page->getId()) {
                 $page->setCurrent(true);
                 $this->setCurrant($page);
             }
             $this->listPage->offsetSet($page->getId(), $page);
         }
     }
     $this->buildFristPage();
     $this->buildLastPage();
 }
Example #11
0
 public function offsetSet($offset, $value)
 {
     if (!isset($this->data)) {
         $this->lazyInitialization();
     }
     if (is_array($value)) {
         $value = new \ArrayObject($value);
     } elseif (!$value instanceof \Traversable) {
         throw new \InvalidArgumentException(sprintf('%s: Value must be an array!', __CLASS__), 1322149789);
     }
     if (isset($this[$offset])) {
         $props = iterator_to_array($value);
         if (isset($props['type'])) {
             unset($props['type']);
         }
         $this->changes[] = array('setProp', $offset, $props);
     } elseif (count($this->types) === 1) {
         $this->changes[] = array('setKey', $offset, $this->types[0], iterator_to_array($value));
     } elseif (isset($value['type'])) {
         $props = iterator_to_array($value);
         unset($props['type']);
         $this->changes[] = array('setKey', $offset, $value['type'], $props);
     } else {
         throw new \LogicException(sprintf('%s: New record `type` was not specified!', __CLASS__), 1397569441);
     }
     $this->data->offsetSet($offset, $value);
 }
 public function render(FrontendController $frontendController, CmsView $view)
 {
     if (!$this->settingsFound) {
         return $this->renderEditable($frontendController, '<p>no settings found</p>');
     }
     $columnsArr = new \ArrayObject();
     for ($i = 1; $i <= $this->settings->cols; ++$i) {
         $colMods = new \ArrayObject();
         if (isset($this->settings->columns[$i]) === true) {
             foreach ($this->settings->columns[$i] as $mod) {
                 if (isset($this->elements[$mod]) === false) {
                     continue;
                 }
                 /** @var CmsElement $modInstance */
                 $modInstance = $this->elements[$mod];
                 $colMods->append($modInstance->render($frontendController, $view));
             }
         }
         $columnsArr->offsetSet($i, $colMods);
     }
     $this->tplVars->offsetSet('columns', $columnsArr);
     $this->tplVars->offsetSet('column_count', $this->settings->cols);
     $this->tplVars->offsetSet('logged_in', $frontendController->getAuth()->isLoggedIn());
     $html = $view->render($this->identifier . '.html', (array) $this->tplVars);
     return $this->renderEditable($frontendController, $html);
 }
 /**
  * Method to add an element to the collection-
  *
  * @param mixed $index
  * @param tx_crawler_domain_process $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function offsetSet($index, $subject)
 {
     if (!$subject instanceof tx_crawler_domain_process) {
         throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!');
     }
     parent::offsetSet($index, $subject);
 }
 /**
  * Sets the value at the specified index to newval
  * @param mixed $index <p>
  * The index being set.
  * </p>
  * @param TagableInterface $newval <p>
  * The new value for the <i>index</i>.
  * </p>
  * @return void
  */
 public function offsetSet($index, $newval)
 {
     if (!$newval instanceof Passenger) {
         throw new \InvalidArgumentException('Invalid passenger object');
     }
     parent::offsetSet($index, $newval);
 }
 /**
  * @param mixed $index
  * @param mixed $newval
  */
 public function offsetSet($index, $newval)
 {
     if (!is_a($newval, $this->allowedClass)) {
         $this->throwInvalid($newval);
     }
     return parent::offsetSet($index, $newval);
 }
Example #16
0
 /**
  * @param string $event
  * @param \Closure $handler
  * @param int $priority
  */
 protected function addEventCallback($event, \Closure $handler, $priority)
 {
     if (!$this->callbacks->offsetExists($event)) {
         $this->callbacks->offsetSet($event, new \Nano\Event\Queue());
     }
     $this->callbacks->offsetGet($event)->insert($handler, $priority);
 }
 /**
  * Sets the value at the specified index to newval
  * @param mixed $index <p>
  * The index being set.
  * </p>
  * @param TagableInterface $newval <p>
  * The new value for the <i>index</i>.
  * </p>
  * @return void
  */
 public function offsetSet($index, $newval)
 {
     if (!$newval instanceof TagableInterface) {
         throw new \InvalidArgumentException('Invalid tagable object');
     }
     parent::offsetSet($index, $newval);
 }
Example #18
0
 /**
  * @param string $attr
  * @param mixed $value
  * @return mixed|null
  */
 public function offsetSet($attr, $value)
 {
     $parent =& $this->queryParser->parent($attr);
     if ($parent === $this or $parent === null or $this->offsetExists($attr)) {
         parent::offsetSet($attr, $value);
         return;
     }
     if ($this->queryParser->exists($attr)) {
         $old =& $this->queryParser->find($attr);
         $old = $value;
     } else {
         if ($parent === null and strlen(str_replace(array('.', '#', '!', '@'), '', ltrim($attr, '.#!@'))) != strlen(ltrim($attr, '.#!@'))) {
             throw new \RuntimeException('Unable to determine parent of ' . $attr . ' for change its value.');
         }
         $qp = new QueryParser($parent);
         switch ($qp->getType()) {
             case QueryParser::TYPE_ARRAY:
             case QueryParser::TYPE_ACCESS:
                 $parent[$attr] = $value;
                 break;
             case QueryParser::TYPE_OBJECT:
                 $parent->{$attr} = $value;
                 break;
         }
     }
 }
Example #19
0
 /**
  * Sets the value at the specified index
  *
  * @param string $key
  * @param mixed  $value
  */
 public function offsetSet($key, $value)
 {
     if (!isset($this->defaults[$key])) {
         throw new \InvalidArgumentException('Unknown key [' . $key . ']');
     }
     parent::offsetSet($key, $value);
 }
Example #20
0
 public function offsetSet($name, $resource)
 {
     if (!$resource instanceof Resource) {
         throw new \InvalidArgumentException('You must provide a resource');
     }
     parent::offsetSet($name, $resource);
 }
Example #21
0
 public function offsetSet($name, $value)
 {
     if (!is_object($value) || !$value instanceof Antwoord) {
         throw new InvalidArgumentException(sprintf('Only objects of Antwoord allowed.'));
     }
     parent::offsetSet($name, $value);
 }
 /**
  * Implementation of ArrayAccess::offsetSet()
  *
  * Overrides ArrayObject::offsetSet() to validate that the value set at the
  * specified offset is a DbInstance.
  *
  * No value is returned.
  *
  * @param mixed $offset
  * @param DbInstanceInterface $value
  */
 public function offsetSet($offset, $value)
 {
     if (!is_subclass_of($value, 'Acquia\\Platform\\Cloud\\Hosting\\DbInstanceInterface')) {
         throw new \InvalidArgumentException(sprintf('%s: $value must be an implementation of DbInstanceInterface', __METHOD__));
     }
     parent::offsetSet($offset, $value);
 }
 public function offsetSet($index, $newval)
 {
     if ($index != NULL) {
         CodeGuard::checkTypeAndThrow($index, 'integer');
     }
     parent::offsetSet($index, $newval);
 }
Example #24
0
 /**
  * @param $name
  * @param $func
  * @param bool $cache
  * @throws \Exception
  */
 public function add($name, $func, $cache = false)
 {
     if (!is_callable($func)) {
         throw new \Exception($func . ' is not callable');
     }
     parent::offsetSet($name, ['func' => $func, 'cache' => $cache]);
 }
 /**
  * Offset to set.
  *
  * @param mixed $index  The offset to assign the value to.
  * @param mixed $newval The value to set.
  *
  * @return void
  * @throws \InvalidArgumentException When invalid element given.
  */
 public function offsetSet($index, $newval)
 {
     if (!$this->assertElement($newval)) {
         return;
     }
     parent::offsetSet($index, $newval);
 }
 /**
  * Schränkt die erlaubten Objekte für die RecordList ein
  * @param string $key
  * @param mixed $value
  * @throws InvalidArgumentException
  */
 public function offsetSet($key, $value)
 {
     if (!$value instanceof DragonX_Storage_Record_Abstract && !$value instanceof DragonX_Storage_RecordList) {
         throw new Dragon_Application_Exception_System('incorrect recordclass', array('recordclass' => get_class($value)));
     }
     parent::offsetSet($key, $value);
 }
Example #27
0
 public function offsetSet($offset, $value)
 {
     if (\is_array($value)) {
         $value = new self($value);
     }
     parent::offsetSet($offset, $value);
 }
 public function offsetSet($index, $newval)
 {
     if (!$newval instanceof DisposableInterface) {
         throw new \InvalidArgumentException(sprintf('%s: only DisposableInterface objects can be stored in this array', __CLASS__), 1326101771);
     }
     parent::offsetSet($index, $newval);
 }
Example #29
0
 /**
  * Set a new option.
  *
  * @param   string  $name    No use here, we use option name.
  * @param   Option  $option  The option object to set in this set.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function offsetSet($name, $option)
 {
     $name = $option->getName();
     $aliases = $option->getAlias();
     $this->setAlias($aliases, $name);
     parent::offsetSet($name, $option);
 }
Example #30
0
 /**
  * ArrayObject::offsetSet
  */
 public function offsetSet($key, $value)
 {
     if (is_array($value)) {
         parent::offsetSet($key, new static($value));
     } else {
         parent::offsetSet($key, $value);
     }
 }