Returns an instance of Mailer.

@param string $key Key that identifies which mailer configuration to load.

@return Mailer
181665
protected static function mailer($key = 'Default')
    {
        if (isset(self::$mailerInstances[$key])) {
            return self::$mailerInstances[$key];
        } else {
            self::$mailerInstances[$key] = new Mailer($key);

            return self::$mailerInstances[$key];
        }
    }
1233047
public function get($key)
    {
        if (isset($this->config[$key])) {
            // if true, 'config' is also always set
            return $this->config[$key]['config'];
        }

        $conf = null;
        $file = $this->getFileNameForKey($key);

        // check if in cache
        if (null !== $this->cache) {
            $cacheKey = $this->getCacheKeyForFile($file);
            $conf = $this->app[$this->cache]->get($cacheKey);
            if (false !== $conf) {
                $this->config[$key] = [
                    'config' => $conf,
                    'cacheKey' => $cacheKey,
                ];

                return $conf;
            }
        }

        // Load from file
        $conf = $this->loader->getConfig($file);
        $this->config[$key] = ['config' => $conf];

        // Store in the cache
        if (null !== $this->cache) {
            $this->config[$key]['cacheKey'] = $cacheKey;
            $this->app[$this->cache]->set($cacheKey, $conf);
        }

        return $conf;
    }
772387
public function get($key = '')
    {
        try {
            if ($this->cacheInstance !== NULL && is_object($this->cacheInstance)) {
                /**
                 * @var $cache object
                 */
                if (is_array($key)) {
                    $cache = $this->cacheInstance->getItems($key);
                } else {
                    $cache = $this->cacheInstance->getItem($key);
                }
                if (!$cache->isHit()) {
                    $result = NULL;
                    $this->debug->debug(__FUNCTION__, 'Unavailable Cache for Key: ' . $key);
                } else {
                    $result = $cache->get();
                    $this->debug->debug(__FUNCTION__, 'Get Cache from Key: ' . $key . ', result: ' . json_encode($result));
                }
                $message = 'Final get Content from Key: ' . $key . ' => Output result: ' . json_encode($result);
                $this->debug->info(__FUNCTION__, $message);

                return $result;
            } else {
                $this->debug->error(__FUNCTION__, 'Unavailable cacheInstance');

                return NULL;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return $message;
        }
    }
424459
public function getArrayAccessor($key)
    {
        $value = $this->get($key);
        if ($value === null or !is_array($value)) {
            return null;
        }
        return new ArrayAccessor($value);
    }
697767
public static function read(string $key)
    {
        /* Check if initialized */
        if (!self::$initialized) {
            self::initialize();
        }

        /* Return key */
        return self::$configs[$key];
    }
1299197
private function getUsingLoaderMethod($key)
    {
        $value = false;

        $loader_method = $this->getLoaderMethod($key);
        if (method_exists($this, $loader_method)) {
            if ($this->hasSubDataObject($key)) {
                // return loaded sub-dataobject
                $value = $this->getSubDataObject($key);
            } else {
                // use loader method to load sub-dataobject
                $this->checkDB();
                $this->setSubDataObject(
                    $key,
                    call_user_func(array($this, $loader_method))
                );

                $value = $this->getSubDataObject($key);
            }
        }

        return $value;
    }
253481
public static function key($key)
    {
        $config = static::where('key', $key)->first();

        return $config->value ?? config($key, null);
    }
118276
function findKey( $key )
    {
        $msg = null;
        if ( isset( $this->Messages[$key] ) )
        {
            $msg = $this->Messages[$key];
        }
        return $msg;
    }
800533
public static function instance(string $key)
    {
        $collection = static::make();

        $class = $collection->get($key);

        if (class_exists($class)) {
            return resolve($class);
        }

        return null;
    }
1193899
static function fromKey(string $key)
    {
        return self::$instanceCache[static::class][$key]
            ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key)));
    }
1121016
public function getMailInstance($config = null)
    {
        if (!$config) {
            $config = $this->config('config');
        }

        $sender = Configure::read('CM.Mail.sender');

        $object = $this->EmailObject;

        $object->sender($sender['email'], $sender['name']);

        if (Configure::read('CM.Mail.transport')) {
            $object->transport(Configure::read('CM.Mail.transport'));
        }

        return $object;
    }
308065
public function getResponseHeader($key = null) {
        if (null != $key) {
            if (array_key_exists($key, $this->response_headers)) {
                return $this->response_headers[$key];
            }
        } else {
            return $this->response_headers;
        }
    }
275604
public function getImporter($key)
    {
        foreach ($this->getImporters(true) as $k => $importer) {
            if ($key === $k) {
                return $importer;
            }
        }
        throw new \InvalidArgumentException(sprintf('Importer could not be found by key `%s`.', $key));
    }
176243
public function findOrCreate($key)
    {
        if ($this->exists($key)) {
            return $this->configs[$key];
        }

        $config = new $this->class();
        $config->setName($key);

        return $config;
    }
678667
public static function get($key)
    {
        if (isset(self::$messages[$key]) === true) {
            return self::$messages[$key];
        }
    }
156316
public function user($key = null) {
		$user = $this->_getUser();
		if ($key === null) {
			return $user;
		}
		return Hash::get($user, $key);
	}
797147
protected function getPageByRequestKey($key)
	{
		$page = $this->searchPageByRequestKey($key);

		if (is_null($page)) {
			$localization = $this->searchLocalizationByRequestKey($key);

			if ( ! is_null($localization)) {
				$page = $localization->getMaster();
			}
		}

		return $page;
	}