Skip to content

Commit

Permalink
[#13915] - Changed the di variable
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Mar 23, 2019
1 parent 1dd565b commit 64c12b8
Show file tree
Hide file tree
Showing 32 changed files with 235 additions and 235 deletions.
22 changes: 11 additions & 11 deletions phalcon/assets/manager.zep
Expand Up @@ -29,7 +29,7 @@ use Phalcon\Di\InjectionAwareInterface;
class Manager implements InjectionAwareInterface
{

protected _dependencyInjector;
protected container;

/**
* Options configure
Expand All @@ -55,9 +55,9 @@ class Manager implements InjectionAwareInterface
/**
* Sets the dependency injector
*/
public function setDI(<DiInterface> dependencyInjector)
public function setDI(<DiInterface> container)
{
let this->container = dependencyInjector;
let this->container = container;
}

/**
Expand Down Expand Up @@ -783,7 +783,7 @@ class Manager implements InjectionAwareInterface
*/
public function outputCss(string collectionName = null) -> string
{
var collection, dependencyInjector, tag, callback;
var collection, container, tag, callback;

if !collectionName {
let collection = this->getCss();
Expand All @@ -793,9 +793,9 @@ class Manager implements InjectionAwareInterface

let callback = ["Phalcon\\Tag", "stylesheetLink"];

let dependencyInjector = this->container;
if typeof dependencyInjector == "object" && dependencyInjector->has("tag") {
let tag = dependencyInjector->getShared("tag");
let container = this->container;
if typeof container == "object" && container->has("tag") {
let tag = container->getShared("tag");
let callback = [tag, "stylesheetLink"];
}

Expand Down Expand Up @@ -823,7 +823,7 @@ class Manager implements InjectionAwareInterface
*/
public function outputJs(string collectionName = null) -> string
{
var collection, dependencyInjector, tag, callback;
var collection, container, tag, callback;

if !collectionName {
let collection = this->getJs();
Expand All @@ -833,9 +833,9 @@ class Manager implements InjectionAwareInterface

let callback = ["Phalcon\\Tag", "javascriptInclude"];

let dependencyInjector = this->container;
if typeof dependencyInjector == "object" && dependencyInjector->has("tag") {
let tag = dependencyInjector->getShared("tag");
let container = this->container;
if typeof container == "object" && container->has("tag") {
let tag = container->getShared("tag");
let callback = [tag, "javascriptInclude"];
}

Expand Down
14 changes: 7 additions & 7 deletions phalcon/cli/console.zep
Expand Up @@ -33,12 +33,12 @@ class Console extends BaseApplication
*/
public function handle(array arguments = null)
{
var dependencyInjector, router, eventsManager,
var container, router, eventsManager,
moduleName, modules, module, path, className,
moduleObject, dispatcher, task;

let dependencyInjector = this->container;
if typeof dependencyInjector != "object" {
let container = this->container;
if typeof container != "object" {
throw new Exception("A dependency injection object is required to access internal services");
}

Expand All @@ -53,7 +53,7 @@ class Console extends BaseApplication
}
}

let router = <Router> dependencyInjector->getShared("router");
let router = <Router> container->getShared("router");

if !count(arguments) && this->arguments {
router->handle(this->arguments);
Expand Down Expand Up @@ -101,10 +101,10 @@ class Console extends BaseApplication
}
}

let moduleObject = dependencyInjector->get(className);
let moduleObject = container->get(className);

moduleObject->registerAutoloaders();
moduleObject->registerServices(dependencyInjector);
moduleObject->registerServices(container);

if typeof eventsManager == "object" {
if eventsManager->fire("console:afterStartModule", this, moduleObject) === false {
Expand All @@ -114,7 +114,7 @@ class Console extends BaseApplication

}

let dispatcher = <\Phalcon\Cli\Dispatcher> dependencyInjector->getShared("dispatcher");
let dispatcher = <\Phalcon\Cli\Dispatcher> container->getShared("dispatcher");

dispatcher->setModuleName(router->getModuleName());
dispatcher->setTaskName(router->getTaskName());
Expand Down
10 changes: 5 additions & 5 deletions phalcon/cli/dispatcher.zep
Expand Up @@ -160,7 +160,7 @@ class Dispatcher extends CliDispatcher implements DispatcherInterface
*/
public function getOption(option, filters = null, defaultValue = null) -> var
{
var options, filter, optionValue, dependencyInjector;
var options, filter, optionValue, container;

let options = this->options;
if !fetch optionValue, options[option] {
Expand All @@ -171,15 +171,15 @@ class Dispatcher extends CliDispatcher implements DispatcherInterface
return optionValue;
}

let dependencyInjector = this->container;
if typeof dependencyInjector != "object" {
let container = this->container;
if typeof container != "object" {
this->{"_throwDispatchException"}(
"A dependency injection object is required to access the 'filter' service",
CliDispatcher::EXCEPTION_NO_DI
);
}
let filter = <LocatorInterface> dependencyInjector->getShared("filter");
// let filter = <FilterInterface> dependencyInjector->getShared("filter");
let filter = <LocatorInterface> container->getShared("filter");
// let filter = <FilterInterface> container->getShared("filter");

return filter->sanitize(optionValue, filters);
}
Expand Down
2 changes: 1 addition & 1 deletion phalcon/di/injectionawareinterface.zep
Expand Up @@ -23,7 +23,7 @@ interface InjectionAwareInterface
/**
* Sets the dependency injector
*/
public function setDI(<DiInterface> dependencyInjector);
public function setDI(<DiInterface> container);

/**
* Returns the internal dependency injector
Expand Down
8 changes: 4 additions & 4 deletions phalcon/di/service.zep
Expand Up @@ -104,7 +104,7 @@ class Service implements ServiceInterface
* @param array parameters
* @return mixed
*/
public function resolve(parameters = null, <DiInterface> dependencyInjector = null)
public function resolve(parameters = null, <DiInterface> container = null)
{
bool found;
var shared, definition, sharedInstance, instance, builder;
Expand Down Expand Up @@ -154,8 +154,8 @@ class Service implements ServiceInterface
/**
* Bounds the closure to the current DI
*/
if typeof dependencyInjector == "object" {
let definition = \Closure::bind(definition, dependencyInjector);
if typeof container == "object" {
let definition = \Closure::bind(definition, container);
}

if typeof parameters == "array" {
Expand All @@ -172,7 +172,7 @@ class Service implements ServiceInterface
*/
if typeof definition == "array" {
let builder = new Builder(),
instance = builder->build(dependencyInjector, definition, parameters);
instance = builder->build(container, definition, parameters);
} else {
let found = false;
}
Expand Down
24 changes: 12 additions & 12 deletions phalcon/di/service/builder.zep
Expand Up @@ -26,7 +26,7 @@ class Builder
*
* @return mixed
*/
private function _buildParameter(<DiInterface> dependencyInjector, int position, array! argument)
private function _buildParameter(<DiInterface> container, int position, array! argument)
{
var type, name, value, instanceArguments;

Expand All @@ -46,10 +46,10 @@ class Builder
if !fetch name, argument["name"] {
throw new Exception("Service 'name' is required in parameter on position " . position);
}
if typeof dependencyInjector != "object" {
if typeof container != "object" {
throw new Exception("The dependency injector container is not valid");
}
return dependencyInjector->get(name);
return container->get(name);

/**
* If the argument type is 'parameter', we assign the value as it is
Expand All @@ -69,21 +69,21 @@ class Builder
throw new Exception("Service 'className' is required in parameter on position " . position);
}

if typeof dependencyInjector != "object" {
if typeof container != "object" {
throw new Exception("The dependency injector container is not valid");
}

if fetch instanceArguments, argument["arguments"] {
/**
* Build the instance with arguments
*/
return dependencyInjector->get(name, instanceArguments);
return container->get(name, instanceArguments);
}

/**
* The instance parameter does not have arguments for its constructor
*/
return dependencyInjector->get(name);
return container->get(name);

default:
/**
Expand All @@ -96,13 +96,13 @@ class Builder
/**
* Resolves an array of parameters
*/
private function _buildParameters(<DiInterface> dependencyInjector, array! arguments) -> array
private function _buildParameters(<DiInterface> container, array! arguments) -> array
{
var position, argument, buildArguments;

let buildArguments = [];
for position, argument in arguments {
let buildArguments[] = this->_buildParameter(dependencyInjector, position, argument);
let buildArguments[] = this->_buildParameter(container, position, argument);
}
return buildArguments;
}
Expand All @@ -113,7 +113,7 @@ class Builder
* @param array parameters
* @return mixed
*/
public function build(<DiInterface> dependencyInjector, array! definition, parameters = null)
public function build(<DiInterface> container, array! definition, parameters = null)
{
var className, arguments, paramCalls, methodPosition, method,
methodName, methodCall, instance, propertyPosition, property,
Expand Down Expand Up @@ -147,7 +147,7 @@ class Builder
/**
* Create the instance based on the parameters
*/
let instance = create_instance_params(className, this->_buildParameters(dependencyInjector, arguments));
let instance = create_instance_params(className, this->_buildParameters(container, arguments));

} else {
let instance = create_instance(className);
Expand Down Expand Up @@ -204,7 +204,7 @@ class Builder
/**
* Call the method on the instance
*/
call_user_func_array(methodCall, this->_buildParameters(dependencyInjector, arguments));
call_user_func_array(methodCall, this->_buildParameters(container, arguments));

/**
* Go to next method call
Expand Down Expand Up @@ -264,7 +264,7 @@ class Builder
/**
* Update the public property
*/
let instance->{propertyName} = this->_buildParameter(dependencyInjector, propertyPosition, propertyValue);
let instance->{propertyName} = this->_buildParameter(container, propertyPosition, propertyValue);
}
}

Expand Down
2 changes: 1 addition & 1 deletion phalcon/di/serviceinterface.zep
Expand Up @@ -49,7 +49,7 @@ interface ServiceInterface
* @param array parameters
* @return mixed
*/
public function resolve(parameters = null, <DiInterface> dependencyInjector = null);
public function resolve(parameters = null, <DiInterface> container = null);

/**
* Changes a parameter in the definition without resolve the service
Expand Down
12 changes: 6 additions & 6 deletions phalcon/flash/session.zep
Expand Up @@ -27,11 +27,11 @@ class Session extends FlashBase
*/
protected function _getSessionMessages(bool remove, type = null) -> array
{
var dependencyInjector, session, messages, returnMessages;
var container, session, messages, returnMessages;

let dependencyInjector = <DiInterface> this->getDI();
let container = <DiInterface> this->getDI();

let session = <SessionInterface> dependencyInjector->getShared("session"),
let session = <SessionInterface> container->getShared("session"),
messages = session->get("_flashMessages");

if typeof type == "string" {
Expand Down Expand Up @@ -59,10 +59,10 @@ class Session extends FlashBase
*/
protected function _setSessionMessages(array! messages) -> array
{
var dependencyInjector, session;
var container, session;

let dependencyInjector = <DiInterface> this->getDI(),
session = <SessionInterface> dependencyInjector->getShared("session");
let container = <DiInterface> this->getDI(),
session = <SessionInterface> container->getShared("session");

session->set("_flashMessages", messages);
return messages;
Expand Down
8 changes: 4 additions & 4 deletions phalcon/forms/form.zep
Expand Up @@ -166,7 +166,7 @@ class Form extends Injectable implements \Countable, \Iterator
public function bind(array! data, var entity, var whitelist = null) -> <Form>
{
var filter, key, value, element, filters,
dependencyInjector, filteredValue, method;
container, filteredValue, method;

if empty this->elements {
throw new Exception("There are no elements in the form");
Expand Down Expand Up @@ -199,9 +199,9 @@ class Form extends Injectable implements \Countable, \Iterator
if filters {

if typeof filter != "object" {
let dependencyInjector = this->getDI(),
filter = <LocatorInterface> dependencyInjector->getShared("filter");
// filter = <FilterInterface> dependencyInjector->getShared("filter");
let container = this->getDI(),
filter = <LocatorInterface> container->getShared("filter");
// filter = <FilterInterface> container->getShared("filter");
}

/**
Expand Down
14 changes: 7 additions & 7 deletions phalcon/mvc/collection/manager.zep
Expand Up @@ -41,7 +41,7 @@ use Phalcon\Mvc\Collection\BehaviorInterface;
class Manager implements InjectionAwareInterface, EventsAwareInterface
{

protected _dependencyInjector;
protected container;

protected _initialized;

Expand All @@ -62,9 +62,9 @@ class Manager implements InjectionAwareInterface, EventsAwareInterface
/**
* Sets the DependencyInjector container
*/
public function setDI(<DiInterface> dependencyInjector) -> void
public function setDI(<DiInterface> container) -> void
{
let this->container = dependencyInjector;
let this->container = container;
}

/**
Expand Down Expand Up @@ -224,7 +224,7 @@ class Manager implements InjectionAwareInterface, EventsAwareInterface
*/
public function getConnection(<CollectionInterface> model)
{
var service, connectionService, connection, dependencyInjector, entityName;
var service, connectionService, connection, container, entityName;

let service = this->_serviceName;
let connectionService = this->_connectionServices;
Expand All @@ -239,15 +239,15 @@ class Manager implements InjectionAwareInterface, EventsAwareInterface
}
}

let dependencyInjector = this->container;
if typeof dependencyInjector != "object" {
let container = this->container;
if typeof container != "object" {
throw new Exception("A dependency injector container is required to obtain the services related to the ORM");
}

/**
* Request the connection service from the DI
*/
let connection = dependencyInjector->getShared(service);
let connection = container->getShared(service);
if typeof connection != "object" {
throw new Exception("Invalid injected connection service");
}
Expand Down

0 comments on commit 64c12b8

Please sign in to comment.