Add an item to the container.

@param string  $id
@param mixed   $concrete
@param boolean $shared

@return \League\Container\Definition\DefinitionInterface
323892
public function add(string $id, $concrete = null, bool $shared = null) : DefinitionInterface
    {
        $concrete = $concrete ?? $id;
        $shared = $shared ?? $this->defaultToShared;

        return $this->definitions->add($id, $concrete, $shared);
    }
1283693
public function retrieve($abstract, array $parameters = [], $shared = true)
  {
    if($shared && isset($this->_instances[$abstract]))
    {
      return $this->_buildInstance($this->_instances[$abstract]['instance'], $parameters);
    }
    if(isset($this->_factories[$abstract]))
    {
      $instance = $this->_factories[$abstract]['generator'](...$parameters);
      if($instance !== null)
      {
        if($shared)
        {
          $this->share($abstract, $instance, $this->_factories[$abstract]['mode']);
        }
        return $instance;
      }
    }
    throw new \Exception("Unable to retrieve");
  }
1247228
public function component($name, $definition, $shared = false)
    {
        $this->container->register($name, $definition, $shared);

        return $this;
    }
276019
public function initiateObject($className, $additionalParameters = array(), $shared = false)
    {
        return $this->dependencyInjectionManager->initiateObject($className, $additionalParameters, $shared);
    }
826086
private function addServiceInclude($id, $definition)
    {
        $template = "        require_once %s;\n";
        $code = '';

        if (null !== $file = $definition->getFile()) {
            $code .= sprintf($template, $this->dumpValue($file));
        }

        foreach ($this->getInlinedDefinitions($definition) as $definition) {
            if (null !== $file = $definition->getFile()) {
                $code .= sprintf($template, $this->dumpValue($file));
            }
        }

        if ('' !== $code) {
            $code .= "\n";
        }

        return $code;
    }
263752
public function addById($id, array $styles)
    {
        $this->ids[$id] = array_merge_recursive($this->getById($id), $styles);
    }
984404
public function add($id, $data = 1)
    {
        try {
            return $this->resource->hSet(static::CACHE_KEY, $id, $data);
        } catch (ConnectionException $e) {
            return false;
        }
    }
189625
private function shareService(Definition $definition, $service, $id)
    {
        if (null !== $id && $definition->isShared()) {
            $this->services[strtolower($id)] = $service;
        }
    }
32025
public function register($id, $definition, $shared = false)
    {
        if (is_object($definition) && !is_callable($definition)) {
            $this->instances[$id] = $definition;

            return $this;
        }

        $this->components[$id] = $definition;

        if ($shared || isset($this->instances[$id])) {
            $this->instances[$id] = null;
        }

        return $this;
    }
1183340
public function loadLayoutIds(bool $includeDrafts, ?bool $shared = null, int $offset = 0, ?int $limit = null): array
    {
        $query = $this->connection->createQueryBuilder();

        $query->select('DISTINCT l.id, l.name')
            ->from('ngbm_layout', 'l');

        if ($includeDrafts) {
            $query->leftJoin(
                'l',
                'ngbm_layout',
                'l2',
                $query->expr()->andX(
                    $query->expr()->eq('l.id', 'l2.id'),
                    $query->expr()->eq('l2.status', ':status')
                )
            );
        }

        if ($shared !== null) {
            $query->where(
                $query->expr()->eq('l.shared', ':shared')
            );
        }

        $statusExpr = $query->expr()->eq('l.status', ':status');
        if ($includeDrafts) {
            $statusExpr = $query->expr()->orX(
                $statusExpr,
                $query->expr()->isNull('l2.id')
            );
        }

        $query->andWhere($statusExpr);

        if ($shared !== null) {
            $query->setParameter('shared', $shared, Type::BOOLEAN);
        }

        $query->setParameter('status', Value::STATUS_PUBLISHED, Type::INTEGER);

        $this->applyOffsetAndLimit($query, $offset, $limit);
        $query->orderBy('l.name', 'ASC');

        $result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return array_column($result, 'id');
    }
551461
public function createObject($class, array $args = [], $shared = false, $protected = false)
    {
        $callback = function (Container $container) use ($class, $args) {
            return $container->newInstance($class, $args);
        };

        return $this->set($class, $callback, $shared, $protected)->get($class);
    }
863555
public function bindIf($abstract, $concrete = null, $shared = false)
    {
        if (! $this->bound($abstract)) {
            $this->bind($abstract, $concrete, $shared);
        }
    }
663774
public function add(string $id): self
    {
        if (!isset($this->data[$id])) {
            $registeredAddon = \BearFramework\Addons::get($id);
            if ($registeredAddon === null) {
                throw new \Exception('The addon ' . $id . ' is not registered!');
            }
            $registeredAddonOptions = $registeredAddon->options;
            if (isset($registeredAddonOptions['require']) && is_array($registeredAddonOptions['require'])) {
                foreach ($registeredAddonOptions['require'] as $requiredAddonID) {
                    if (is_string($requiredAddonID) && !isset($this->data[$requiredAddonID])) {
                        $this->add($requiredAddonID);
                    }
                }
            }

            $dir = $registeredAddon->dir;
            $this->data[$id] = new \BearFramework\App\Addon($id, $dir);
            $this->app->contexts->add($dir);
        }
        return $this;
    }
126329
public function share_with_group(string $id, string $id_group, bool $cancel = false): ?int
  {
    if ( $cfg = $this->get($id) ){

      $id_share = $this->db->select_one($this->class_table, $this->fields['id'], [
        'id_alias' => $id,
        'id_group' => $id_group
      ]);
      if ( $cancel && $id_share ){
        return $this->db->delete($this->class_table, [$this->fields['id'] => $id_share]);
      }
      else if ( !$cancel && !$id_share ){
        return $this->db->insert($this->class_table, [
          'id_option' => $cfg['id_option'],
          'id_alias' => $id,
          'id_group' => $id_group
        ]);
      }
      return 0;
    }
    return null;
  }
410895
public function definition($concrete = null, array $args = [])
    {
        /**
         * @todo validate that $concrete is a string or null
         */

        $definition = new Definition($this, $concrete, $args);

        return $definition;
    }
654296
public function makeBlockShared($id)
    {
        if ($this->em->getFilters()->isEnabled('draftversion')) {
            $this->em->getFilters()->disable('draftversion');
        }

        $block = $this->find($id);
        $version = $this->getNewVersion($block);

        // Duplicate some of the settings to the pointer
        $pointer = new PointerBlock();
        $pointer->setOwner($block->getOwner());
        $pointer->setParent($block->getParent());
        $pointer->setReference($block);
        $pointer->setRootVersion($version);

        // Detach and make shared
        $block->setShared(true);
        $block->setParent(null);
        $block->setOwner(null);
        $block->setPosition(0);
        $block->setSort(0);
        $block->setRootVersion($version);


        $this->killLoggableListener();

        $this->save($block)->save($pointer);

        return $pointer;
    }
1305187
public function addTransaction(int $id, StoreRequest $request)
    {
        /** @var HasTransactionsInterface $object */
        if(!$object = $this->repository->find($id)) {
            abort(404);
        }

        $transaction = $object->addTransaction( $request->all() );

        event(new MadeTransaction($transaction));

        \Cache::tags('response')->flush();

        return new TransactionResource($transaction);
    }