本文整理汇总了PHP中ArrayObject::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::offsetSet方法的具体用法?PHP ArrayObject::offsetSet怎么用?PHP ArrayObject::offsetSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::offsetSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
/**
* 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;
}
示例2: addResult
/**
* 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);
}
示例3: processQueue
/**
* 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;
}
示例4: addConfigItem
/**
* 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;
}
示例5: set
/**
* @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);
}
示例6: setOptions
/**
* 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);
}
}
示例7: getFieldDescriptor
/**
* 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);
}
示例8: registerService
/**
* 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);
}
示例9: table
/**
* 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);
}
示例10: buildListPage
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();
}
示例11: offsetSet
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);
}
示例12: render
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);
}
示例13: offsetSet
/**
* 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);
}
示例14: offsetSet
/**
* 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);
}
示例15: offsetSet
/**
* @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);
}