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


PHP Collection::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param array|Collection $parameters Collection of parameters
  *      to set on the command
  * @param ApiCommand $apiCommand Command definition from description
  */
 public function __construct($parameters = null, ApiCommand $apiCommand = null)
 {
     parent::__construct($parameters);
     if ($apiCommand) {
         $this->apiCommand = $apiCommand;
     } else {
         // If this is a concrete command, then build an ApiCommand object
         $className = get_class($this);
         // Determine the name of the command based on the relation to the
         // client that executes the command
         $this->apiCommand = new ApiCommand(array('name' => str_replace('\\_', '.', Inflector::snake(substr($className, strpos($className, 'Command') + 8))), 'class' => $className, 'params' => $this->getInspector()->getApiParamsForClass($className)));
     }
     // Set default values on the command
     $this->getInspector()->validateConfig($this->apiCommand->getParams(), $this, false, false);
     $headers = $this->get('headers');
     if (!$headers instanceof Collection) {
         $this->set('headers', new Collection((array) $headers));
     }
     // You can set a command.on_complete option in your parameters as a
     // convenience method for setting an onComplete function
     $onComplete = $this->get('command.on_complete');
     if ($onComplete) {
         $this->remove('command.on_complete');
         $this->setOnComplete($onComplete);
     }
     $this->init();
 }
开发者ID:norv,项目名称:guzzle,代码行数:34,代码来源:AbstractCommand.php

示例2: __construct

 /**
  * @param array|Collection   $parameters Collection of parameters to set on the command
  * @param OperationInterface $operation Command definition from description
  */
 public function __construct($parameters = array(), OperationInterface $operation = null)
 {
     parent::__construct($parameters);
     $this->operation = $operation ?: $this->createOperation();
     foreach ($this->operation->getParams() as $name => $arg) {
         $currentValue = $this[$name];
         $configValue = $arg->getValue($currentValue);
         // If default or static values are set, then this should always be updated on the config object
         if ($currentValue !== $configValue) {
             $this[$name] = $configValue;
         }
     }
     $headers = $this[self::HEADERS_OPTION];
     if (!$headers instanceof Collection) {
         $this[self::HEADERS_OPTION] = new Collection((array) $headers);
     }
     // You can set a command.on_complete option in your parameters to set an onComplete callback
     if ($onComplete = $this['command.on_complete']) {
         unset($this['command.on_complete']);
         $this->setOnComplete($onComplete);
     }
     // Set the hidden additional parameters
     if (!$this[self::HIDDEN_PARAMS]) {
         $this[self::HIDDEN_PARAMS] = array(self::HEADERS_OPTION, self::RESPONSE_PROCESSING, self::HIDDEN_PARAMS, self::REQUEST_OPTIONS);
     }
     $this->init();
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:AbstractCommand.php

示例3: __construct

 /**
  * Constructor
  *
  * @param array|Collection   $parameters Collection of parameters to set on the command
  * @param OperationInterface $operation Command definition from description
  */
 public function __construct($parameters = null, OperationInterface $operation = null)
 {
     parent::__construct($parameters);
     $this->operation = $operation ?: $this->createOperation();
     foreach ($this->operation->getParams() as $name => $arg) {
         $currentValue = $this->get($name);
         $configValue = $arg->getValue($currentValue);
         // If default or static values are set, then this should always be updated on the config object
         if ($currentValue !== $configValue) {
             $this->set($name, $configValue);
         }
     }
     $headers = $this->get(self::HEADERS_OPTION);
     if (!$headers instanceof Collection) {
         $this->set(self::HEADERS_OPTION, new Collection((array) $headers));
     }
     // You can set a command.on_complete option in your parameters to set an onComplete callback
     if ($onComplete = $this->get('command.on_complete')) {
         $this->remove('command.on_complete');
         $this->setOnComplete($onComplete);
     }
     // If no response processing value was specified, then attempt to use the highest level of processing
     if (!$this->get(self::RESPONSE_PROCESSING)) {
         $this->set(self::RESPONSE_PROCESSING, self::TYPE_MODEL);
     }
     $this->init();
 }
开发者ID:xkeygmbh,项目名称:ifresco-php,代码行数:33,代码来源:AbstractCommand.php

示例4: __construct

 /**
  * Construct collection from models indexed by name
  * @param array $models Associative array of data to set
  * @throws \Exception if circular references cannot be resolved.
  */
 public function __construct(array $models = array())
 {
     parent::__construct();
     // build dependency graph and add missing id properties
     $graph = array();
     foreach ($models as $id => $model) {
         if (!isset($model['id'])) {
             $models[$id]['id'] = $id;
         }
         $graph[$id] = self::collectRefs($model);
         // allow self-dependency
         unset($graph[$id][$id]);
     }
     // Add items with no dependencies until no items have dependencies left
     while ($models) {
         $n = 0;
         foreach (array_keys($models) as $id) {
             if (empty($graph[$id])) {
                 $n++;
                 // add item with no dependencies to collection
                 $this->set($id, $models[$id]);
                 unset($models[$id]);
                 // remove added item from dependency list of others
                 foreach ($graph as $ref => $references) {
                     unset($graph[$ref][$id]);
                 }
             }
         }
         if (!$n) {
             throw new \Exception('circular references in model depenencies');
         }
     }
 }
开发者ID:rodsouto,项目名称:swizzle,代码行数:38,代码来源:ModelCollection.php

示例5: __construct

 /**
  * Phlack Constructor.
  *
  * @param mixed $client
  *
  * @throws UnexpectedTypeException
  */
 public function __construct($client)
 {
     if (is_string($client) || is_array($client)) {
         $client = new PhlackClient($client);
     } elseif (!$client instanceof PhlackClient) {
         throw new UnexpectedTypeException($client, ['string', 'array', 'Crummy\\Phlack\\Bridge\\Guzzle\\PhlackClient']);
     }
     parent::__construct(['client' => $client, 'builders' => [], 'commands' => ['send' => 'Send']]);
 }
开发者ID:mcrumm,项目名称:phlack,代码行数:16,代码来源:Phlack.php

示例6: __construct

 /**
  * Constructor
  *
  * @param array|Collection $parameters (optional) Collection of parameters
  *      to set on the command
  * @param ApiCommand $apiCommand (optional) Command definition from description
  */
 public function __construct($parameters = null, ApiCommand $apiCommand = null)
 {
     parent::__construct($parameters);
     // Add arguments and defaults to the command
     if ($apiCommand) {
         $this->apiCommand = $apiCommand;
         Inspector::getInstance()->validateConfig($apiCommand->getParams(), $this, false, false);
     } else {
         Inspector::getInstance()->validateClass(get_class($this), $this, false, false);
     }
     if (!$this->get('headers') instanceof Collection) {
         $this->set('headers', new Collection((array) $this->get('headers')));
     }
     $this->init();
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:22,代码来源:AbstractCommand.php

示例7: __construct

 /**
  * Constructor
  *
  * @param array|Collection    $parameters Collection of parameters to set on the command
  * @param ApiCommandInterface $apiCommand Command definition from description
  */
 public function __construct($parameters = null, ApiCommandInterface $apiCommand = null)
 {
     parent::__construct($parameters);
     $this->apiCommand = $apiCommand ?: ApiCommand::fromCommand(get_class($this));
     $this->initConfig();
     $headers = $this->get(self::HEADERS_OPTION);
     if (!$headers instanceof Collection) {
         $this->set(self::HEADERS_OPTION, new Collection((array) $headers));
     }
     // You can set a command.on_complete option in your parameters as a
     // convenience method for setting an onComplete function
     $onComplete = $this->get('command.on_complete');
     if ($onComplete) {
         $this->remove('command.on_complete');
         $this->setOnComplete($onComplete);
     }
     $this->init();
 }
开发者ID:nickpeirson,项目名称:guzzle,代码行数:24,代码来源:AbstractCommand.php

示例8: __construct

 public function __construct($parameters = array(), OperationInterface $operation = null)
 {
     parent::__construct($parameters);
     $this->operation = $operation ?: $this->createOperation();
     foreach ($this->operation->getParams() as $name => $arg) {
         $currentValue = $this[$name];
         $configValue = $arg->getValue($currentValue);
         if ($currentValue !== $configValue) {
             $this[$name] = $configValue;
         }
     }
     $headers = $this[self::HEADERS_OPTION];
     if (!$headers instanceof Collection) {
         $this[self::HEADERS_OPTION] = new Collection((array) $headers);
     }
     if ($onComplete = $this['command.on_complete']) {
         unset($this['command.on_complete']);
         $this->setOnComplete($onComplete);
     }
     if (!$this[self::HIDDEN_PARAMS]) {
         $this[self::HIDDEN_PARAMS] = array(self::HEADERS_OPTION, self::RESPONSE_PROCESSING, self::HIDDEN_PARAMS, self::REQUEST_OPTIONS);
     }
     $this->init();
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:24,代码来源:AbstractCommand.php

示例9: __construct

 /**
  * Constructs the PostObject
  *
  * The options array accepts the following keys:
  *
  * - acl:                          The access control setting to apply to the uploaded file. Accepts any of the
  *                                 CannedAcl constants
  * - Cache-Control:                The Cache-Control HTTP header value to apply to the uploaded file
  * - Content-Disposition:          The Content-Disposition HTTP header value to apply to the uploaded file
  * - Content-Encoding:             The Content-Encoding HTTP header value to apply to the uploaded file
  * - Content-Type:                 The Content-Type HTTP header value to apply to the uploaded file. The default
  *                                 value is `application/octet-stream`
  * - Expires:                      The Expires HTTP header value to apply to the uploaded file
  * - key:                          The location where the file should be uploaded to. The default value is
  *                                 `^${filename}` which will use the name of the uploaded file
  * - policy:                       A raw policy in JSON format. By default, the PostObject creates one for you
  * - success_action_redirect:      The URI for Amazon S3 to redirect to upon successful upload
  * - success_action_status:        The status code for Amazon S3 to return upon successful upload
  * - ttd:                          The expiration time for the generated upload form data
  * - x-amz-server-side-encryption: The server-side encryption mechanism to use
  * - x-amz-storage-class:          The storage setting to apply to the object
  * - x-amz-meta-*:                 Any custom meta tag that should be set to the object
  *
  * For the Cache-Control, Content-Disposition, Content-Encoding,
  * Content-Type, Expires, and key options, to use a "starts-with" comparison
  * instead of an equals comparison, prefix the value with a ^ (carat)
  * character
  *
  * @param S3Client $client
  * @param $bucket
  * @param array $options
  */
 public function __construct(S3Client $client, $bucket, array $options = array())
 {
     $this->setClient($client);
     $this->setBucket($bucket);
     parent::__construct($options);
 }
开发者ID:claybbs,项目名称:namedmanager,代码行数:38,代码来源:PostObject.php

示例10: __construct

 /**
  * @param array $data
  */
 public function __construct($data = [])
 {
     $resolver = new OptionsResolver();
     $this->setDefaultOptions($resolver);
     parent::__construct($resolver->resolve($data));
 }
开发者ID:mcrumm,项目名称:phlack,代码行数:9,代码来源:Hash.php


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