Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Object manager
* Retrieve list of arguments per type
* @param string $type
* @return array
public function getArguments($type)
if (isset($this->arguments[$type])) {
if (is_string($this->arguments[$type])) {
$this->arguments[$type] = unserialize($this->arguments[$type]);
return $this->arguments[$type];
} else {
return [['_i_' => 'Magento\Framework\ObjectManagerInterface']];
So if for any type arguments cannot be found it will return Object manager object
We use for magento2 projects
so anywhere in the code we can use
\MaxMind\Db\ReaderFactory in a way
$readerFactory->create(['database' => 'path/to/file.mmdb');
above works on in default/develop mode
but in production mode - actual value of passed variable $database is Object manager, not string as required

This comment has been minimized.

Copy link

@antonkril antonkril commented Oct 18, 2016

This happens because compiler does not read MaxMindDBReader directory, so it does not collect constructor signature information from it. So compiled class definition config does not know that DB\Reader has a $database argument.

It works like that because it is too expensive to compile vendor directory. But we plan to fix it in an efficient way.

Anyway, we always recommend to not depend on third-party libraries directly, and implement adapters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment