From cd537fa60402ace4ea03d33355138699aea1ae77 Mon Sep 17 00:00:00 2001 From: Anthony GRASSIOT Date: Sat, 4 Feb 2017 18:09:56 +0100 Subject: [PATCH] remove more deprecated methods usage --- src/Console/ConsoleIo.php | 4 ++-- src/Controller/Component.php | 2 +- src/Controller/Component/AuthComponent.php | 12 +++++------ src/Controller/Controller.php | 20 +++++++++---------- src/Core/StaticConfigTrait.php | 2 +- src/Datasource/EntityTrait.php | 6 +++--- src/Datasource/RulesAwareTrait.php | 4 ++-- src/Mailer/Email.php | 4 ++-- src/ORM/Association/HasMany.php | 2 +- src/ORM/Behavior/CounterCacheBehavior.php | 8 ++++---- src/ORM/Behavior/Translate/TranslateTrait.php | 2 +- src/ORM/Entity.php | 2 +- src/ORM/Marshaller.php | 6 +++--- src/ORM/Table.php | 4 ++-- src/View/StringTemplate.php | 2 +- src/View/View.php | 4 ++-- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Console/ConsoleIo.php b/src/Console/ConsoleIo.php index 294d4036c23..d452d248364 100644 --- a/src/Console/ConsoleIo.php +++ b/src/Console/ConsoleIo.php @@ -377,13 +377,13 @@ public function setLoggers($enable) 'types' => $outLevels, 'stream' => $this->_out ]); - Log::config('stdout', ['engine' => $stdout]); + Log::setConfig('stdout', ['engine' => $stdout]); } $stderr = new ConsoleLog([ 'types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'stream' => $this->_err, ]); - Log::config('stderr', ['engine' => $stderr]); + Log::setConfig('stderr', ['engine' => $stderr]); } /** diff --git a/src/Controller/Component.php b/src/Controller/Component.php index cc2faead243..7ab480d2b08 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -51,7 +51,7 @@ * propagation. * * While the controller is not an explicit argument for the callback methods it - * is the subject of each event and can be fetched using Event::subject(). + * is the subject of each event and can be fetched using Event::getSubject(). * * @link http://book.cakephp.org/3.0/en/controllers/components.html * @see \Cake\Controller\Controller::$components diff --git a/src/Controller/Component/AuthComponent.php b/src/Controller/Component/AuthComponent.php index f944821ce1d..8735c9d0ef3 100644 --- a/src/Controller/Component/AuthComponent.php +++ b/src/Controller/Component/AuthComponent.php @@ -387,7 +387,7 @@ protected function _unauthenticated(Controller $controller) } if (!empty($this->_config['ajaxLogin'])) { - $controller->viewBuilder()->templatePath('Element'); + $controller->viewBuilder()->setTemplatePath('Element'); $response = $controller->render( $this->_config['ajaxLogin'], $this->RequestHandler->ajaxLayout @@ -745,8 +745,8 @@ protected function _getUser() if (!empty($result) && is_array($result)) { $this->_authenticationProvider = $auth; $event = $this->dispatchEvent('Auth.afterIdentify', [$result, $auth]); - if ($event->result() !== null) { - $result = $event->result(); + if ($event->getResult() !== null) { + $result = $event->getResult(); } $this->storage()->write($result); @@ -777,7 +777,7 @@ protected function _getUser() */ public function redirectUrl($url = null) { - $redirectUrl = $this->request->query(static::QUERY_STRING_REDIRECT); + $redirectUrl = $this->request->getQuery(static::QUERY_STRING_REDIRECT); if ($redirectUrl && (substr($redirectUrl, 0, 1) !== '/' || substr($redirectUrl, 0, 2) === '//')) { $redirectUrl = null; } @@ -821,8 +821,8 @@ public function identify() if (!empty($result)) { $this->_authenticationProvider = $auth; $event = $this->dispatchEvent('Auth.afterIdentify', [$result, $auth]); - if ($event->result() !== null) { - return $event->result(); + if ($event->getResult() !== null) { + return $event->getResult(); } return $result; diff --git a/src/Controller/Controller.php b/src/Controller/Controller.php index d2c04c01549..3a11a4b2f1d 100644 --- a/src/Controller/Controller.php +++ b/src/Controller/Controller.php @@ -500,12 +500,12 @@ protected function _loadComponents() public function startupProcess() { $event = $this->dispatchEvent('Controller.initialize'); - if ($event->result() instanceof Response) { - return $event->result(); + if ($event->getResult() instanceof Response) { + return $event->getResult(); } $event = $this->dispatchEvent('Controller.startup'); - if ($event->result() instanceof Response) { - return $event->result(); + if ($event->getResult() instanceof Response) { + return $event->getResult(); } return null; @@ -523,8 +523,8 @@ public function startupProcess() public function shutdownProcess() { $event = $this->dispatchEvent('Controller.shutdown'); - if ($event->result() instanceof Response) { - return $event->result(); + if ($event->getResult() instanceof Response) { + return $event->getResult(); } return null; @@ -549,8 +549,8 @@ public function redirect($url, $status = 302) } $event = $this->dispatchEvent('Controller.beforeRedirect', [$url, $response]); - if ($event->result() instanceof Response) { - return $this->response = $event->result(); + if ($event->getResult() instanceof Response) { + return $this->response = $event->getResult(); } if ($event->isStopped()) { return null; @@ -608,8 +608,8 @@ public function render($view = null, $layout = null) $this->autoRender = false; $event = $this->dispatchEvent('Controller.beforeRender'); - if ($event->result() instanceof Response) { - return $event->result(); + if ($event->getResult() instanceof Response) { + return $event->getResult(); } if ($event->isStopped()) { return $this->response; diff --git a/src/Core/StaticConfigTrait.php b/src/Core/StaticConfigTrait.php index 49674054210..032c04123b9 100644 --- a/src/Core/StaticConfigTrait.php +++ b/src/Core/StaticConfigTrait.php @@ -292,7 +292,7 @@ public static function parseDsn($dsn) $parsed = $queryArgs + $parsed; if (empty($parsed['className'])) { - $classMap = static::dsnClassMap(); + $classMap = static::getDsnClassMap(); $parsed['className'] = $parsed['scheme']; if (isset($classMap[$parsed['scheme']])) { diff --git a/src/Datasource/EntityTrait.php b/src/Datasource/EntityTrait.php index 695bfdeb1c5..87d3ceba35f 100644 --- a/src/Datasource/EntityTrait.php +++ b/src/Datasource/EntityTrait.php @@ -242,11 +242,11 @@ public function set($property, $value = null, array $options = []) $options += ['setter' => true, 'guard' => $guard]; foreach ($property as $p => $value) { - if ($options['guard'] === true && !$this->accessible($p)) { + if ($options['guard'] === true && !$this->isAccessible($p)) { continue; } - $this->dirty($p, true); + $this->setDirty($p, true); if (!array_key_exists($p, $this->_original) && array_key_exists($p, $this->_properties) && @@ -658,7 +658,7 @@ public function extract(array $properties, $onlyDirty = false) { $result = []; foreach ($properties as $property) { - if (!$onlyDirty || $this->dirty($property)) { + if (!$onlyDirty || $this->isDirty($property)) { $result[$property] = $this->get($property); } } diff --git a/src/Datasource/RulesAwareTrait.php b/src/Datasource/RulesAwareTrait.php index 65aa6cca24a..e0cb3aea002 100644 --- a/src/Datasource/RulesAwareTrait.php +++ b/src/Datasource/RulesAwareTrait.php @@ -59,7 +59,7 @@ public function checkRules(EntityInterface $entity, $operation = RulesChecker::C compact('entity', 'options', 'operation') ); if ($event->isStopped()) { - return $event->result(); + return $event->getResult(); } } @@ -72,7 +72,7 @@ public function checkRules(EntityInterface $entity, $operation = RulesChecker::C ); if ($event->isStopped()) { - return $event->result(); + return $event->getResult(); } } diff --git a/src/Mailer/Email.php b/src/Mailer/Email.php index bae719ca1fd..3990c2f6bf8 100644 --- a/src/Mailer/Email.php +++ b/src/Mailer/Email.php @@ -339,7 +339,7 @@ public function __construct($config = null) ->setHelpers(['Html']); if ($config === null) { - $config = static::config('default'); + $config = static::getConfig('default'); } if ($config) { $this->setProfile($config); @@ -2102,7 +2102,7 @@ protected function _applyConfig($config) { if (is_string($config)) { $name = $config; - $config = static::config($name); + $config = static::getConfig($name); if (empty($config)) { throw new InvalidArgumentException(sprintf('Unknown email configuration "%s".', $name)); } diff --git a/src/ORM/Association/HasMany.php b/src/ORM/Association/HasMany.php index a7aff92af0d..cdeede6484b 100644 --- a/src/ORM/Association/HasMany.php +++ b/src/ORM/Association/HasMany.php @@ -264,7 +264,7 @@ public function link(EntityInterface $sourceEntity, array $targetEntities, array $sourceEntity->set($property, $currentEntities); - $savedEntity = $this->connection()->transactional(function () use ($sourceEntity, $options) { + $savedEntity = $this->getConnection()->transactional(function () use ($sourceEntity, $options) { return $this->saveAssociated($sourceEntity, $options); }); diff --git a/src/ORM/Behavior/CounterCacheBehavior.php b/src/ORM/Behavior/CounterCacheBehavior.php index 56621c2d7b0..1b8f0f679ce 100644 --- a/src/ORM/Behavior/CounterCacheBehavior.php +++ b/src/ORM/Behavior/CounterCacheBehavior.php @@ -116,8 +116,8 @@ public function beforeSave(Event $event, EntityInterface $entity) continue; } - $registryAlias = $assoc->target()->registryAlias(); - $entityAlias = $assoc->property(); + $registryAlias = $assoc->getTarget()->getRegistryAlias(); + $entityAlias = $assoc->getProperty(); if (!is_callable($config) && isset($config['ignoreDirty']) && @@ -201,8 +201,8 @@ protected function _processAssociation(Event $event, EntityInterface $entity, As $config = []; } - if (isset($this->_ignoreDirty[$assoc->target()->registryAlias()][$field]) && - $this->_ignoreDirty[$assoc->target()->registryAlias()][$field] === true + if (isset($this->_ignoreDirty[$assoc->getTarget()->getRegistryAlias()][$field]) && + $this->_ignoreDirty[$assoc->getTarget()->getRegistryAlias()][$field] === true ) { continue; } diff --git a/src/ORM/Behavior/Translate/TranslateTrait.php b/src/ORM/Behavior/Translate/TranslateTrait.php index b98738d416e..7df9077250b 100644 --- a/src/ORM/Behavior/Translate/TranslateTrait.php +++ b/src/ORM/Behavior/Translate/TranslateTrait.php @@ -58,7 +58,7 @@ public function translation($language) } // Assume the user will modify any of the internal translations, helps with saving - $this->dirty('_translations', true); + $this->setDirty('_translations', true); return $i18n[$language]; } diff --git a/src/ORM/Entity.php b/src/ORM/Entity.php index ce96056d757..6eea8da3e50 100644 --- a/src/ORM/Entity.php +++ b/src/ORM/Entity.php @@ -56,7 +56,7 @@ public function __construct(array $properties = [], array $options = []) ]; if (!empty($options['source'])) { - $this->source($options['source']); + $this->setSource($options['source']); } if ($options['markNew'] !== null) { diff --git a/src/ORM/Marshaller.php b/src/ORM/Marshaller.php index d2c7edce735..4f29cdacadc 100644 --- a/src/ORM/Marshaller.php +++ b/src/ORM/Marshaller.php @@ -170,11 +170,11 @@ public function one(array $data, array $options = []) $entityClass = $this->_table->getEntityClass(); /* @var Entity $entity */ $entity = new $entityClass(); - $entity->source($this->_table->getRegistryAlias()); + $entity->setSource($this->_table->getRegistryAlias()); if (isset($options['accessibleFields'])) { foreach ((array)$options['accessibleFields'] as $key => $value) { - $entity->accessible($key, $value); + $entity->setAccess($key, $value); } } $errors = $this->_validate($data, $options, true); @@ -210,7 +210,7 @@ public function one(array $data, array $options = []) $entity->set($properties); } - $entity->errors($errors); + $entity->setErrors($errors); return $entity; } diff --git a/src/ORM/Table.php b/src/ORM/Table.php index eabf3e9c393..8cfa54d3638 100644 --- a/src/ORM/Table.php +++ b/src/ORM/Table.php @@ -1771,7 +1771,7 @@ protected function _processSave($entity, $options) $event = $this->dispatchEvent('Model.beforeSave', compact('entity', 'options')); if ($event->isStopped()) { - return $event->result(); + return $event->getResult(); } $saved = $this->_associations->saveParents( @@ -2099,7 +2099,7 @@ protected function _processDelete($entity, $options) ]); if ($event->isStopped()) { - return $event->result(); + return $event->getResult(); } $this->_associations->cascadeDelete( diff --git a/src/View/StringTemplate.php b/src/View/StringTemplate.php index 7899d1f6071..7b1cc6f9ec1 100644 --- a/src/View/StringTemplate.php +++ b/src/View/StringTemplate.php @@ -29,7 +29,7 @@ class StringTemplate { use InstanceConfigTrait { - config as get; + getConfig as get; } /** diff --git a/src/View/View.php b/src/View/View.php index 819ae50fff4..714b51713f4 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -971,8 +971,8 @@ protected function _render($viewFile, $data = []) $content = $this->_evaluate($viewFile, $data); $afterEvent = $this->dispatchEvent('View.afterRenderFile', [$viewFile, $content]); - if ($afterEvent->result() !== null) { - $content = $afterEvent->result(); + if ($afterEvent->getResult() !== null) { + $content = $afterEvent->getResult(); } if (isset($this->_parents[$viewFile])) {