Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed ArrayAccess interface for Container and Controller
- Loading branch information
Showing
3 changed files
with
7 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
* | ||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> | ||
*/ | ||
class Controller extends ContainerAware implements \ArrayAccess | ||
class Controller extends ContainerAware | ||
{ | ||
/** | ||
* Creates a Response instance. | ||
|
@@ -113,47 +113,26 @@ public function render($view, array $parameters = array(), Response $response = | |
} | ||
|
||
/** | ||
* Returns true if the service id is defined (implements the ArrayAccess interface). | ||
* Returns true if the service id is defined. | ||
* | ||
* @param string $id The service id | ||
* | ||
* @return Boolean true if the service id is defined, false otherwise | ||
*/ | ||
public function offsetExists($id) | ||
public function has($id) | ||
{ | ||
return $this->container->has($id); | ||
} | ||
|
||
/** | ||
* Gets a service by id (implements the ArrayAccess interface). | ||
* Gets a service by id. | ||
* | ||
* @param string $id The service id | ||
* | ||
* @return mixed The parameter value | ||
* @return object The service | ||
*/ | ||
public function offsetGet($id) | ||
public function get($id) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Seldaek
Member
|
||
{ | ||
return $this->container->get($id); | ||
} | ||
|
||
/** | ||
* Sets a service (implements the ArrayAccess interface). | ||
* | ||
* @param string $id The service id | ||
* @param object $value The service | ||
*/ | ||
public function offsetSet($id, $value) | ||
{ | ||
throw new \LogicException(sprintf('You can\'t set a service from a controller (%s).', $id)); | ||
} | ||
|
||
/** | ||
* Removes a service (implements the ArrayAccess interface). | ||
* | ||
* @param string $id The service id | ||
*/ | ||
public function offsetUnset($id) | ||
{ | ||
throw new \LogicException(sprintf('You can\'t unset a service from a controller (%s).', $id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think it would be nice to expose some method to list available services or get container.
Use case:
I wanted to get kernel environment, but I don't know how to get kernel and I can't list services. If you expose getServiceIds or container, I can see what services are available and what are their Ids. I lost some time to figure that I need to $this->get('kernel')->getEnvironment();