CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.3 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.3
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
      • Attribute
      • Configure
      • Exception
      • Retry
      • TestSuite
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Container

Dependency Injection container

Based on the container out of League\Container

Namespace: Cake\Core

Property Summary

  • $delegates protected
    ContainerInterface[]
  • $eventDispatcher protected
    ?EventDispatcher

Method Summary

  • __construct() public
  • add() public
  • addListener() public
  • addServiceProvider() public
  • addShared() public
  • afterResolve() public
  • defaultToOverwrite() public
  • defaultToShared() public
  • delegate() public
  • dispatchEvent() protected
  • extend() public
  • get() public

    Finds an entry of the container by its identifier and returns it.

  • getDefinitionTags() protected
  • getDelegate() public
  • getEventDispatcher() public
  • getNew() public
  • has() public

    Returns true if the container can return an entry for the given identifier. Returns false otherwise.

  • inflector() public deprecated
  • listen() public
  • resolve() protected
  • setEventDispatcher() public

Method Detail

__construct() ¶ public

__construct(DefinitionAggregateInterface $definitions = new DefinitionAggregate(), ServiceProviderAggregateInterface $providers = new ServiceProviderAggregate(), InflectorAggregateInterface $inflectors = new InflectorAggregate(), bool $defaultToShared = false, bool $defaultToOverwrite = false)
Parameters
DefinitionAggregateInterface $definitions optional
ServiceProviderAggregateInterface $providers optional
InflectorAggregateInterface $inflectors optional
bool $defaultToShared optional
bool $defaultToOverwrite optional

add() ¶ public

add(string $id, mixed $concrete = null, bool $overwrite = false): DefinitionInterface
Parameters
string $id
mixed $concrete optional
bool $overwrite optional
Returns
DefinitionInterface

addListener() ¶ public

addListener(string $eventType, callable $listener): void
Parameters
string $eventType
callable $listener
Returns
void

addServiceProvider() ¶ public

addServiceProvider(ServiceProviderInterface $provider): self
Parameters
ServiceProviderInterface $provider
Returns
self

addShared() ¶ public

addShared(string $id, mixed $concrete = null, bool $overwrite = false): DefinitionInterface
Parameters
string $id
mixed $concrete optional
bool $overwrite optional
Returns
DefinitionInterface

afterResolve() ¶ public

afterResolve(string $type, callable $callback): EventFilter
Parameters
string $type
callable $callback
Returns
EventFilter

defaultToOverwrite() ¶ public

defaultToOverwrite(bool $overwrite = true): ContainerInterface
Parameters
bool $overwrite optional
Returns
ContainerInterface

defaultToShared() ¶ public

defaultToShared(bool $shared = true): ContainerInterface
Parameters
bool $shared optional
Returns
ContainerInterface

delegate() ¶ public

delegate(Psr\Container\ContainerInterface $container): Psr\Container\ContainerInterface
Parameters
Psr\Container\ContainerInterface $container

The container instance to use as delegation

Returns
Psr\Container\ContainerInterface

dispatchEvent() ¶ protected

dispatchEvent(ContainerEvent $event): ContainerEvent
Parameters
ContainerEvent $event
Returns
ContainerEvent

extend() ¶ public

extend(string $id): DefinitionInterface
Parameters
string $id
Returns
DefinitionInterface

get() ¶ public

get(string $id): mixed

Finds an entry of the container by its identifier and returns it.

Parameters
string $id

Identifier of the entry to look for.

Returns
mixed

Entry.

Throws
NotFoundExceptionInterface
No entry was found for **this** identifier.
ContainerExceptionInterface
Error while retrieving the entry.

getDefinitionTags() ¶ protected

getDefinitionTags(DefinitionInterface $definition): array
Parameters
DefinitionInterface $definition
Returns
array

getDelegate() ¶ public

getDelegate(string $class): ContainerInterface
Parameters
string $class
Returns
ContainerInterface

getEventDispatcher() ¶ public

getEventDispatcher(): ?EventDispatcher
Returns
?EventDispatcher

getNew() ¶ public

getNew(string $id): mixed
Parameters
string $id
Returns
mixed

has() ¶ public

has(string $id): bool

Returns true if the container can return an entry for the given identifier. Returns false otherwise.

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundExceptionInterface.

Parameters
string $id

Identifier of the entry to look for.

Returns
bool

inflector() ¶ public

inflector(string $type, ?callable $callback = null): InflectorInterface
Parameters
string $type
?callable $callback optional
Returns
InflectorInterface

listen() ¶ public

listen(string $eventType, callable $listener): EventFilter
Parameters
string $eventType
callable $listener
Returns
EventFilter

resolve() ¶ protected

resolve(string $id, bool $new = false): mixed
Parameters
string $id
bool $new optional
Returns
mixed
Throws
ContainerExceptionInterface

NotFoundExceptionInterface

setEventDispatcher() ¶ public

setEventDispatcher(?EventDispatcher $eventDispatcher): void
Parameters
?EventDispatcher $eventDispatcher
Returns
void

Property Detail

$delegates ¶ protected

Type
ContainerInterface[]

$eventDispatcher ¶ protected

Type
?EventDispatcher
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs