当前位置: 首页>>代码示例>>PHP>>正文


PHP PriorityQueue::insert方法代码示例

本文整理汇总了PHP中Zend\Stdlib\PriorityQueue::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP PriorityQueue::insert方法的具体用法?PHP PriorityQueue::insert怎么用?PHP PriorityQueue::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Stdlib\PriorityQueue的用法示例。


在下文中一共展示了PriorityQueue::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPath

 /**
  * {@inheritDoc}
  */
 public function addPath($path)
 {
     if (is_string($path)) {
         $this->paths->insert($this->normalizePath($path), 1);
         return;
     }
     if (!is_array($path) && !$path instanceof ArrayAccess) {
         throw new Exception\InvalidArgumentException(sprintf('Provided path must be an array or an instance of ArrayAccess, %s given', is_object($path) ? get_class($path) : gettype($path)));
     }
     if (isset($path['priority']) && isset($path['path'])) {
         $this->paths->insert($this->normalizePath($path['path']), $path['priority']);
         return;
     }
     throw new Exception\InvalidArgumentException('Provided array must contain both keys "priority" and "path"');
 }
开发者ID:sokac,项目名称:AssetManager,代码行数:18,代码来源:PrioritizedPathsResolver.php

示例2: __clone

    /**
     * Make a deep clone of a fieldset
     *
     * @return void
     */
    public function __clone()
    {
        $items = $this->iterator->toArray(PriorityQueue::EXTR_BOTH);

        $this->byName    = array();
        $this->elements  = array();
        $this->fieldsets = array();
        $this->iterator  = new PriorityQueue();

        foreach ($items as $item) {
            $elementOrFieldset = clone $item['data'];
            $name = $elementOrFieldset->getName();

            $this->iterator->insert($elementOrFieldset, $item['priority']);
            $this->byName[$name] = $elementOrFieldset;

            if ($elementOrFieldset instanceof FieldsetInterface) {
                $this->fieldsets[$name] = $elementOrFieldset;
            } elseif ($elementOrFieldset instanceof ElementInterface) {
                $this->elements[$name] = $elementOrFieldset;
            }
        }

        // Also make a deep copy of the object in case it's used within a collection
        if (is_object($this->object)) {
            $this->object = clone $this->object;
        }
    }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:33,代码来源:Fieldset.php

示例3: add

 public function add($elementOrFieldset, $flags = array())
 {
     if (is_array($elementOrFieldset) || $elementOrFieldset instanceof \Traversable && !$elementOrFieldset instanceof Element) {
         $elementOrFieldset = $this->getFormFactory()->create($elementOrFieldset);
     }
     if (!$elementOrFieldset instanceof Element) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that $elementOrFieldset be an object implementing %s; received "%s"', __METHOD__, __NAMESPACE__ . '\\Element', is_object($elementOrFieldset) ? get_class($elementOrFieldset) : gettype($elementOrFieldset)));
     }
     $name = $elementOrFieldset->getName();
     if ((null === $name || '' === $name) && (!array_key_exists('name', $flags) || $flags['name'] === '')) {
         throw new Exception\InvalidArgumentException(sprintf('%s: element or fieldset provided is not named, and no name provided in flags', __METHOD__));
     }
     if (array_key_exists('name', $flags) && $flags['name'] !== '') {
         $name = $flags['name'];
         // Rename the element or fieldset to the specified alias
         $elementOrFieldset->setName($name);
     }
     $elementOrFieldset->setForm($this);
     $order = 0;
     if (array_key_exists('priority', $flags)) {
         $order = $flags['priority'];
     }
     $this->iterator->insert($elementOrFieldset, $order);
     $this->byName[$name] = $elementOrFieldset;
     if ($elementOrFieldset instanceof Fieldset) {
         $this->fieldsetArray[$name] = $elementOrFieldset;
         return $this;
     }
     $this->elementArray[$name] = $elementOrFieldset;
     return $this;
 }
开发者ID:slkxmail,项目名称:App,代码行数:31,代码来源:Fieldset.php

示例4: prependValidator

 /**
  * Adds a validator to the beginning of the chain
  *
  * If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain,
  * if one exists, will not be executed.
  *
  * @param  ValidatorInterface      $validator
  * @param  bool                 $breakChainOnFailure
  * @return ValidatorChain Provides a fluent interface
  */
 public function prependValidator(ValidatorInterface $validator, $breakChainOnFailure = false)
 {
     $priority = self::DEFAULT_PRIORITY;
     if (!$this->validators->isEmpty()) {
         $extractedNodes = $this->validators->toArray(PriorityQueue::EXTR_PRIORITY);
         rsort($extractedNodes, SORT_NUMERIC);
         $priority = $extractedNodes[0] + 1;
     }
     $this->validators->insert(['instance' => $validator, 'breakChainOnFailure' => (bool) $breakChainOnFailure], $priority);
     return $this;
 }
开发者ID:MadCat34,项目名称:zend-validator,代码行数:21,代码来源:ValidatorChain.php

示例5: attach

 /**
  * Attach a filter to the chain
  *
  * @param  callable|FilterInterface $callback A Filter implementation or valid PHP callback
  * @param  int $priority Priority at which to enqueue filter; defaults to 1000 (higher executes earlier)
  * @throws Exception\InvalidArgumentException
  * @return FilterChain
  */
 public function attach($callback, $priority = self::DEFAULT_PRIORITY)
 {
     if (!is_callable($callback)) {
         if (!$callback instanceof FilterInterface) {
             throw new Exception\InvalidArgumentException(sprintf('Expected a valid PHP callback; received "%s"', is_object($callback) ? get_class($callback) : gettype($callback)));
         }
         $callback = array($callback, 'filter');
     }
     $this->filters->insert($callback, $priority);
     return $this;
 }
开发者ID:royaltyclubvp,项目名称:BuzzyGals,代码行数:19,代码来源:FilterChain.php

示例6: prependValidator

 /**
  * Adds a validator to the beginning of the chain
  *
  * If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain,
  * if one exists, will not be executed.
  *
  * @param  ValidatorInterface      $validator
  * @param  bool                 $breakChainOnFailure
  * @return ValidatorChain Provides a fluent interface
  */
 public function prependValidator(ValidatorInterface $validator, $breakChainOnFailure = false)
 {
     $priority = self::DEFAULT_PRIORITY;
     if (!$this->validators->isEmpty()) {
         $queue = $this->validators->getIterator();
         $queue->setExtractFlags(PriorityQueue::EXTR_PRIORITY);
         $extractedNode = $queue->extract();
         $priority = $extractedNode[0] + 1;
     }
     $this->validators->insert(array('instance' => $validator, 'breakChainOnFailure' => (bool) $breakChainOnFailure), $priority);
     return $this;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:22,代码来源:ValidatorChain.php

示例7: __construct

 public function __construct(ServiceLocatorInterface $serviceManager, $options = array())
 {
     $this->serviceManager = $serviceManager;
     //set the default theme paths (LIFO order)
     $this->themePaths = new PriorityQueue();
     if (isset($options['theme_paths'])) {
         $priority = 1;
         foreach ($options['theme_paths'] as $path) {
             $this->themePaths->insert($path, $priority++);
         }
     }
     //set up theme selector adapters (LIFO order)
     $this->adapters = new PriorityQueue();
     if (isset($options['adapters'])) {
         $priority = 1;
         foreach ($options['adapters'] as $adapterClass) {
             $adapter = new $adapterClass($serviceManager);
             $this->adapters->insert($adapter, $priority++);
         }
     }
 }
开发者ID:bb-drummer,项目名称:ZeTheme,代码行数:21,代码来源:Manager.php

示例8: addJS

 /**
  * Add a JS
  * @param string $path
  * @param int (optional) $priority
  * @return self
  */
 public function addJS($path, $priority = self::DEFAULT_ASSET_PRIORITY, $attributes = null)
 {
     $path = $this->calculateUrl($path, $this->jsPath);
     $tagAttributes = array();
     $tagAttributes['src'] = $path . '?v=' . $this->jsVersion;
     $tagAttributes['type'] = 'text/javascript';
     if (isset($attributes) && is_array($attributes)) {
         $tagAttributes = array_merge($tagAttributes, $attributes);
     }
     $tag = new Tag('script', $tagAttributes);
     $this->jsQueue->insert($tag, $priority);
     return $this;
 }
开发者ID:mrubiosan,项目名称:asset,代码行数:19,代码来源:AssetManager.php

示例9: addCollector

 /**
  * Adds a collector.
  *
  * @param  Collector\CollectorInterface $collector
  * @return self
  * @throws Exception\CollectorException
  */
 public function addCollector($collector)
 {
     if (!isset($this->collectors)) {
         $this->collectors = new PriorityQueue();
     }
     if ($collector instanceof Collector\CollectorInterface) {
         $this->collectors->insert($collector, $collector->getPriority());
     } else {
         $error = sprintf('%s must implement CollectorInterface.', get_class($collector));
         if ($this->strict === true) {
             throw new Exception\CollectorException($error);
         }
         $this->report->addError($error);
     }
     return $this;
 }
开发者ID:lafaiDev,项目名称:suive_com,代码行数:23,代码来源:Profiler.php

示例10: __clone

 /**
  * Make a deep clone of a fieldset
  *
  * @return void
  */
 public function __clone()
 {
     $this->iterator = new PriorityQueue();
     foreach ($this->byName as $key => $value) {
         $value = clone $value;
         $this->byName[$key] = $value;
         $this->iterator->insert($value);
         if ($value instanceof FieldsetInterface) {
             $this->fieldsets[$key] = $value;
         } elseif ($value instanceof ElementInterface) {
             $this->elements[$key] = $value;
         }
     }
     // Also make a deep copy of the object in case it's used within a collection
     if (is_object($this->object)) {
         $this->object = clone $this->object;
     }
 }
开发者ID:navassouza,项目名称:zf2,代码行数:23,代码来源:Fieldset.php

示例11: add

    /**
     * Add an element or fieldset
     *
     * $flags could contain metadata such as the alias under which to register 
     * the element or fieldset, order in which to prioritize it, etc.
     * 
     * @todo   Should we detect if the element/fieldset name conflicts?
     * @param  ElementInterface $elementOrFieldset 
     * @param  array $flags
     * @return FieldsetInterface
     */
    public function add($elementOrFieldset, array $flags = array())
    {
        if (!$elementOrFieldset instanceof ElementInterface) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s requires that $elementOrFieldset be an object implementing %s; received "%s"',
                __METHOD__,
                __NAMESPACE__ . '\ElementInterface',
                (is_object($elementOrFieldset) ? get_class($elementOrFieldset) : gettype($elementOrFieldset))
            ));
        }

        $name = $elementOrFieldset->getName();
        if (empty($name) && (!array_key_exists('name', $flags) || empty($flags['name']))) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s: element or fieldset provided is not named, and no name provided in flags',
                __METHOD__
            ));
        }

        if (array_key_exists('name', $flags) && !empty($flags['name'])) {
            $name = $flags['name'];

            // Rename the element or fieldset to the specified alias
            $elementOrFieldset->setName($name);
        }
        $order = 0;
        if (array_key_exists('priority', $flags)) {
            $order = $flags['priority'];
        }

        $this->iterator->insert($elementOrFieldset, $order);
        $this->byName[$name] = $elementOrFieldset;

        if ($elementOrFieldset instanceof FieldsetInterface) {
            $this->fieldsets[$name] = $elementOrFieldset;
            return $this;
        }

        $this->elements[$name] = $elementOrFieldset;
        return $this;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:52,代码来源:Fieldset.php

示例12: addContext

 /**
  * @param CartContextInterface $cartContext
  * @param int $priority
  */
 public function addContext(CartContextInterface $cartContext, $priority = 0)
 {
     $this->cartContexts->insert($cartContext, $priority);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:8,代码来源:CompositeCartContext.php

示例13: createPriorityQueue

 /**
  * Create the priority queue
  * 
  * @return void
  */
 protected function createPriorityQueue()
 {
     $queue = new PriorityQueue();
     foreach ($this->prioritizedValues as $data) {
         // Do not include priority 0 in list
         if ($data['priority'] == 0) {
             continue;
         }
         // Hack to ensure priorities are correct; was not treating
         // fractional values correctly
         $queue->insert($data['media_type'], (double) $data['priority'] * 10);
     }
     $this->priorityQueue = $queue;
 }
开发者ID:ranxin1022,项目名称:zf2,代码行数:19,代码来源:Accept.php

示例14: addHandler

 /**
  * @param LocaleChangeHandlerInterface $localeChangeHandler
  * @param int $priority
  */
 public function addHandler(LocaleChangeHandlerInterface $localeChangeHandler, $priority = 0)
 {
     $this->handlers->insert($localeChangeHandler, $priority);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:8,代码来源:CompositeLocaleChangeHandler.php

示例15: attach

 /**
  * Attach a resolver
  *
  * @param  ResolverInterface $resolver
  * @param  int               $priority
  * @return self
  */
 public function attach(ResolverInterface $resolver, $priority = 1)
 {
     $this->queue->insert($resolver, $priority);
 }
开发者ID:CPDS,项目名称:Sistema-de-controle-cpds,代码行数:11,代码来源:AggregateResolver.php


注:本文中的Zend\Stdlib\PriorityQueue::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。