make() публичный Метод

This method behave like get() except it forces the scope to "prototype", which means the definition of the entry will be re-evaluated each time. For example, if the entry is a class, then a new instance will be created each time. This method makes the container behave like a factory.
public make ( string $name, array $parameters = [] ) : mixed
$name string Entry name or a class name.
$parameters array Optional parameters to use to build the entry. Use this to force specific parameters to specific values. Parameters not defined in this array will be resolved using the container.
Результат mixed
Пример #1
0
 /**
  * Widget constructor.
  *
  * @param string $widgetClassNameOrAlias
  * @param Container $container
  */
 public function __construct($widgetClassNameOrAlias, Container $container)
 {
     $instance = $container->make($widgetClassNameOrAlias, ['wpWidget' => $this]);
     if (!in_array(WidgetInterface::class, class_implements($instance))) {
         throw new RuntimeException("Incorrect widget class name or widget does not implement WidgetInterface");
     }
     /**
      * Check if instance have listeners for wordpress
      * events which should be registered while
      * widget registering.
      */
     if ($instance instanceof ActionInterface || $instance instanceof DataFilterInterface) {
         $container->get('EventManager')->attachListeners($instance);
     }
     $this->getInstance = function () use($instance) {
         return $instance;
     };
     $params = $instance->getParams();
     $controlOption = [];
     if ($params instanceof ControlableInterface) {
         $controlOption = $params->getControlOptions();
     }
     parent::__construct($params->getId(), $params->getName(), $params->getOptions(), $controlOption);
 }
Пример #2
0
 /**
  *
  * {@inheritDoc}
  * @see \Piita\ClientInterface::projects()
  */
 public function projects()
 {
     return $this->container->make('projects')->get();
 }
Пример #3
0
 /**
  * Activates the given plugin during an update.
  *
  * If the plugin is already activated or if any other error occurs it will be ignored.
  *
  * @param string $pluginName
  * @return Activate
  */
 public function activate($pluginName)
 {
     return $this->container->make('Piwik\\Updater\\Migration\\Plugin\\Activate', array('pluginName' => $pluginName));
 }
Пример #4
0
 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * Please note that queries for batch inserts are currently not shown to an end user and should therefore not be
  * returned in an `Updates::getMigrations` method. Instead it needs to be execute directly in `Updates::doUpdate`
  * via `$updater->executeMigration($factory->dbBatchInsert(...));`
  *
  * @param string $table  Unprefixed database table name, eg 'log_visit'.
  * @param string[] $columnNames An array of unquoted column names, eg array('column_name1', 'column_name_2')
  * @param array $values An array of data to be inserted, eg array(array('row1column1', 'row1column2'),array('row2column1', 'row2column2'))
  * @param bool $throwException Whether to throw an exception that was caught while trying LOAD DATA INFILE, or not.
  * @param string $charset The charset to use, defaults to utf8
  * @return BatchInsert
  */
 public function batchInsert($table, $columnNames, $values, $throwException = false, $charset = 'utf8')
 {
     $table = $this->prefixTable($table);
     return $this->container->make('Piwik\\Updater\\Migration\\Db\\BatchInsert', array('table' => $table, 'columnNames' => $columnNames, 'values' => $values, 'throwException' => $throwException, 'charset' => $charset));
 }
Пример #5
0
<?php

namespace PHPSTORM_META;

$STATIC_METHOD_TYPES = [\Interop\Container\ContainerInterface::get('') => ['guzzle' instanceof \Guzzle\Http\Client], \DI\Container::make('') => []];
Пример #6
0
 /**
  * @param $class
  * @param array $params
  * @return mixed
  * @throws \DI\NotFoundException
  */
 public function make($class, array $params = [])
 {
     return $this->phpDiContainer->make($class, $params);
 }