{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/11442","repository_url":"https://api.github.com/repos/phalcon/cphalcon","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11442/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11442/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11442/events","html_url":"https://github.com/phalcon/cphalcon/issues/11442","id":135896925,"number":11442,"title":"[2.1.x] Di Closure $this by declared object.","user":{"login":"fenixphp","id":3776512,"avatar_url":"https://avatars.githubusercontent.com/u/3776512?v=3","gravatar_id":"","url":"https://api.github.com/users/fenixphp","html_url":"https://github.com/fenixphp","followers_url":"https://api.github.com/users/fenixphp/followers","following_url":"https://api.github.com/users/fenixphp/following{/other_user}","gists_url":"https://api.github.com/users/fenixphp/gists{/gist_id}","starred_url":"https://api.github.com/users/fenixphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenixphp/subscriptions","organizations_url":"https://api.github.com/users/fenixphp/orgs","repos_url":"https://api.github.com/users/fenixphp/repos","events_url":"https://api.github.com/users/fenixphp/events{/privacy}","received_events_url":"https://api.github.com/users/fenixphp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-02-23T23:17:19Z","updated_at":"2016-06-10T20:11:52Z","closed_at":"2016-06-10T20:10:14Z","body":"If you call a method in the class, \"$this\" behavior contrary to the rest of \"Closure\" in \"PHP\".\r\n```php\r\nclass Application extends \\Phalcon\\Mvc\\Application {\r\n  \r\n  public function init() {\r\n    /* Init common service unit. */\r\n    include __DIR__ . '/../Service.php';\r\n\r\n    /* Init http core service unit. */\r\n    include __DIR__ . '/Service.php';\r\n\r\n    /* loopBack. */\r\n    return $this;\r\n  }\r\n\r\n}\r\n\r\n// File Service.php\r\n\r\n/**\r\n * A pointer to calling object.\r\n * @var \\Core\\Mvc\\Application $this\r\n */\r\n\r\n/* Init crypt. */\r\n$this->di->set('crypt', function() {\r\n  $crypt = new \\Phalcon\\Crypt();\r\n  $crypt->setCipher('rijndael-256');\r\n  $crypt->setKey(\r\n    hash(\r\n      'SHA256',\r\n      $this->config->get('App.cryptKey'),\r\n      true\r\n    )\r\n  );\r\n\r\n  return $crypt;\r\n});\r\n\r\n```\r\n\r\nor\r\n\r\n```php\r\nclass Application extends \\Phalcon\\Mvc\\Application {\r\n  \r\n  public function init() {\r\n    \r\n/* Init crypt. */\r\n$this->di->set('crypt', function() {\r\n  $crypt = new \\Phalcon\\Crypt();\r\n  $crypt->setCipher('rijndael-256');\r\n  $crypt->setKey(\r\n    hash(\r\n      'SHA256',\r\n      $this->config->get('App.cryptKey'),\r\n      true\r\n    )\r\n  );\r\n\r\n  return $crypt;\r\n});\r\n\r\n    /* loopBack. */\r\n    return $this;\r\n  }\r\n\r\n}\r\n```\r\n\r\nInstead of ``` $this->config->get('App.cryptKey') ``` must do so ``` $this->get('config')->get('App.cryptKey') ```.\r\n\r\nBased Documents PHP \"$hits\" in the \"Closure\" must be an object in which \"Closure\" declared a.\r\n"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/225283661","html_url":"https://github.com/phalcon/cphalcon/issues/11442#issuecomment-225283661","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11442","id":225283661,"user":{"login":"fenixphp","id":3776512,"avatar_url":"https://avatars.githubusercontent.com/u/3776512?v=3","gravatar_id":"","url":"https://api.github.com/users/fenixphp","html_url":"https://github.com/fenixphp","followers_url":"https://api.github.com/users/fenixphp/followers","following_url":"https://api.github.com/users/fenixphp/following{/other_user}","gists_url":"https://api.github.com/users/fenixphp/gists{/gist_id}","starred_url":"https://api.github.com/users/fenixphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenixphp/subscriptions","organizations_url":"https://api.github.com/users/fenixphp/orgs","repos_url":"https://api.github.com/users/fenixphp/repos","events_url":"https://api.github.com/users/fenixphp/events{/privacy}","received_events_url":"https://api.github.com/users/fenixphp/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T20:11:52Z","updated_at":"2016-06-10T20:11:52Z","body":"Так я уже и сам накостылял :) ... Sorry for my English."}}
{"actor":{"display_login":"fenixphp"}}