Создание управляющего коасса для зпгрузки медиавложений моделей
@param $config
@param null $currentFilename
@param null $newFileData
@return mixed
422151
public static function createUploadableFile($config, $currentFilename = null, $newFileData = null)
    {
        $className = '\\PhpDevil\\framework\\base\\helpers\\files\\' . ucfirst($config['type']) . 'File';
        return new $className($config, $currentFilename, $newFileData);
    }
959076
public static function newInstance($name, $data = null)
  {
    if (!is_array($data)) {
      $data = array();
    }

    $config = self::getInstance($name);
    $config->_data = $data;

    return $config;
  }
683440
public function calculateFieldInfo($currentValue, array $fieldData)
    {
        if (! $currentValue) {
            return $currentValue;
        }

        $agenda      = $this->loader->getAgenda();
        $appointment = $agenda->getAppointment($currentValue);

        if ($appointment && $appointment->isActive()) {
            $time = $appointment->getAdmissionTime();

            if ($time) {
                return $time->toString($this->appointmentTimeFormat);
            }
        }

        return null;
    }
455697
public function getPackageFromConfigFile($config)
    {
        if (!file_exists($config)) {
            throw new \RuntimeException('File "'.$config.'" not found');
        }

        return $this->loader->load((new JsonFile($config))->read(), 'Composer\Package\RootPackage');
    }
678341
public function calculateFieldInfo($currentValue, array $fieldData)
    {
        if (! $currentValue) {
            return $currentValue;
        }

        $lookup = $this->getLookup();

        if (isset($lookup[$currentValue])) {
            return $lookup[$currentValue];
        }

        return null;
    }
85471
public function replace($currentFile, $config)
    {
        $patterns = array(
            'constants' => array(
                '`EKA_[A-Z_]+`',
            ), 'php'    => array(
                '__DIR__',
            ),
        );

        if (!is_array($config)) {

            foreach ($patterns['constants'] as $pattern) {
                if ((bool) preg_match_all($pattern, $config, $matches)) {

                    $matches   = array_unique($matches[0]);
                    $constants = array();//'.' => '');

                    foreach ($matches as $index => $constant) {
                        $constants[$constant] = constant($constant);
                    }

                    $config = str_replace(array_keys($constants), array_values($constants), $config);

                    if (is_numeric($config)) {
                        $config = (int) $config;
                    }
                }
            }

            $currentDir = dirname($currentFile);
            foreach ($patterns['php'] as $pattern) {

                if (strpos($pattern, $config) !== false) {
                    switch ($pattern) {
                        case '__DIR__':
                            $replace = $currentDir;
                            break;
                        default:
                            continue 2;
                    }

                    $config = str_replace($pattern, $replace, $config);
                }
            }

            if (false !== strpos($config, '..')) {
                $config = realpath($config);
            }
        } elseif (is_array($config)) {

            foreach ($config as $key => $conf) {
                $config[$key] = $this->replace($currentFile, $conf);
            }
        }

        return $config;
    }
93593
protected function getConfigData($config)
    {
        if (is_string($config)) {
            if (!file_exists($config)) {
                throw new \InvalidArgumentException("Config file $config not found");
            }
            $this->loadConfigFile($config);
        } elseif (is_array($config)) {
            $this->loadFromHash($config);
        }

        $this->loadConfigFile('iron.ini');
        $this->loadConfigFile('iron.json');

        $this->loadFromEnv(strtoupper($this->product_name));
        $this->loadFromEnv('IRON');

        if (!ini_get('open_basedir')) {
            $this->loadConfigFile(self::homeDir() . '.iron.ini');
            $this->loadConfigFile(self::homeDir() . '.iron.json');
        }

        $this->loadFromHash($this->default_values);

        if (empty($this->token) || empty($this->project_id)) {
            throw new \InvalidArgumentException("token or project_id not found in any of the available sources");
        }
    }
1132006
public function findOrAddNew($data = array(), $config = array())
    {
        $entity = $this->find($data);

        if (!$entity) {
            $entity = $this->addNew($data, $config);
        }

        return $entity;
    }
988703
public function toFile($filename, ObjectConfigInterface $config)
    {
        $pathinfo = pathinfo($filename);

        if (!isset($pathinfo['extension']))
        {
            throw new \RuntimeException(sprintf(
                'Filename "%s" is missing an extension and cannot be auto-detected', $filename
            ));
        }

        $this->createFormat($pathinfo['extension'])->toFile($filename, $config);
        return $this;
    }
435615
private function getCurrentMailer(array $config)
    {
        if ($this->mailer !== null) {
            return $this->mailer;
        }

        if ($config['mailer'] == 'smtp') {
            $transport = \Swift_SmtpTransport::newInstance(
                $config['smtpHost'],
                $config['smtpPort'],
                $config['smtpSecurity']
            );
            $transport->setUsername($config['smtpUsername']);
            $transport->setPassword($config['smtpPassword']);
        } elseif ($config['mailer'] == 'mail') {
            $transport = \Swift_MailTransport::newInstance();
        } else {
            $transport = \Swift_SendmailTransport::newInstance();
        }

        return \Swift_Mailer::newInstance($transport);
    }
1179221
public function templateEditVars($newEditFile)
    {
        File::put($newEditFile, str_replace('%%crudName%%', $this->crudName, File::get($newEditFile)));
        File::put($newEditFile, str_replace('%%crudNameSingular%%', $this->crudNameSingular, File::get($newEditFile)));
        File::put($newEditFile, str_replace('%%modelName%%', $this->modelName, File::get($newEditFile)));
        File::put($newEditFile, str_replace('%%routeGroup%%', $this->routeGroup, File::get($newEditFile)));
        File::put($newEditFile, str_replace('%%formFieldsHtml%%', $this->formFieldsHtml, File::get($newEditFile)));
    }
1164741
public function getNewFile($type = null)
    {
        $class = $this->getFileModelName($type);
        /** @var ModelFile $file */
        $file = new $class();
        $file->setModel($this);
        $file->setFilesystem($this->getFilesystemDisk());
        return $file;
    }
1132087
public function mergeConfig(SiteConfig $currentConfig, SiteConfig $newConfig)
    {
        // check for commands where we accept multiple statements (no test_url)
        foreach (['title', 'body', 'strip', 'strip_id_or_class', 'strip_image_src', 'single_page_link', 'next_page_link', 'date', 'author', 'strip_attr'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_unique(array_merge($currentConfig->$var, $newConfig->$var));
        }

        // special handling of if_page_contains directive
        foreach (['single_page_link'] as $var) {
            if (isset($currentConfig->if_page_contains[$var]) && isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = array_merge($newConfig->if_page_contains[$var], $currentConfig->if_page_contains[$var]);
            } elseif (isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = $newConfig->if_page_contains[$var];
            }
        }

        // check for single statement commands
        // we do not overwrite existing non null values
        foreach (['tidy', 'prune', 'parser', 'autodetect_on_failure', 'requires_login', 'skip_json_ld'] as $var) {
            if ($currentConfig->$var === null) {
                $currentConfig->$var = $newConfig->$var;
            }
        }

        // treat find_string and replace_string separately (don't apply array_unique) (thanks fabrizio!)
        foreach (['find_string', 'replace_string'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_merge($currentConfig->$var, $newConfig->$var);
        }

        // merge http_header array from currentConfig into newConfig
        // because final values override former values in case of named keys
        $currentConfig->http_header = array_merge($newConfig->http_header, $currentConfig->http_header);

        return $currentConfig;
    }
441343
public function loadConfig($config = null)
    {
        $config =
            !is_null($config) || !file_exists($this->configFile)
                ? $this->setConfigFile($this->getConfigFile($config))
                : $this->configFile;

        return $this->loadToLaravelConfig($config);
    }
1246682
public function generateObject($current)
	{
		$nodeWorking = null;
		// Criando o objeto que conterá a lista
		switch ($this->_easyListType)
		{
			case EasyListType::CHECKBOX:
			{
				XmlUtil::CreateChild($current, "caption", $this->_caption);
				$nodeWorking = $current;
				$iHid = new XmlInputHidden("qty" . $this->_name, count($this->_values));
				$iHid->generateObject($nodeWorking);
				break;
			}
			case EasyListType::RADIOBOX:
			{
				XmlUtil::CreateChild($current, "caption", $this->_caption);
				$nodeWorking = $current;
				break;
			}
			case EasyListType::SELECTLIST:
			case EasyListType::SELECTIMAGELIST:
			{
				if ($this->_readOnly)
				{
					if ($this->_easyListType == EasyListType::SELECTLIST)
					{
						$deliLeft = (strlen($this->_readOnlyDeli) != 0 ? $this->_readOnlyDeli[0] : "");
						$deliRight = (strlen($this->_readOnlyDeli) != 0 ? $this->_readOnlyDeli[1] : "");
									
						//XmlInputHidden $xih
						//XmlInputLabelField $xlf
						$xlf = new XmlInputLabelField($this->_caption, $deliLeft . $this->_values[$this->_selected] . $deliRight);
						$xih = new XmlInputHidden($this->_name, $this->_selected);
						$xlf->generateObject($current);
						$xih->generateObject($current);
					}
					elseif ($this->_easyListType == EasyListType::SELECTIMAGELIST)
					{
						$img = new XmlnukeImage($this->_values[$this->_selected]);
						$img->generateObject($current);
					}
					return;
				}
				else
				{
					$nodeWorking = XmlUtil::CreateChild($current, "select", "");
					XmlUtil::AddAttribute($nodeWorking, "caption", $this->_caption);
					XmlUtil::AddAttribute($nodeWorking, "name", $this->_name);
					if($this->_required)
					{
						XmlUtil::AddAttribute($nodeWorking , "required", "true");
					}
					if($this->_size > 1)
					{
						XmlUtil::AddAttribute($nodeWorking , "size", $this->_size);
					}
					
					if ($this->_easyListType == EasyListType::SELECTIMAGELIST)
					{
						XmlUtil::AddAttribute($nodeWorking , "imagelist", "true");
						XmlUtil::AddAttribute($nodeWorking , "thumbnailsize", $this->_thumbnailSize);
						XmlUtil::AddAttribute($nodeWorking , "notfoundimage", $this->_notFoundImage);
						XmlUtil::AddAttribute($nodeWorking , "noimage", $this->_noImage);
					}
				}
				break;
			}
			case EasyListType::UNORDEREDLIST:
			{
				XmlUtil::CreateChild($current, "b", $this->_caption);
				$nodeWorking = XmlUtil::CreateChild($current, "ul", "");
				break;
			}
		}
		
		$i = 0;
		
		foreach($this->_values as $key => $value)
		{
			switch ($this->_easyListType)
			{
				case EasyListType::CHECKBOX:
				{
//					XmlInputCheck $iCk
					$iCk = new XmlInputCheck($value, $this->_name . ($i++), $key);
					$iCk->setType(InputCheckType::CHECKBOX);
					$iCk->setChecked($key == $this->_selected);
					$iCk->setReadOnly($this->_readOnly);
					$iCk->generateObject($nodeWorking);
					break;
				}
				case EasyListType::RADIOBOX:
				{
//					XmlInputCheck $iCk
					$iCk = new XmlInputCheck($value, $this->_name, $key);
					$iCk->setType(InputCheckType::RADIOBOX);
					$iCk->setChecked($key == $this->_selected);
					$iCk->setReadOnly($this->_readOnly);
					$iCk->generateObject($nodeWorking);
					break;
				}
				case EasyListType::SELECTLIST:
				case EasyListType::SELECTIMAGELIST:
				{
					$node = XmlUtil::CreateChild($nodeWorking, "option", "");
					XmlUtil::AddAttribute($node, "value", $key);
					if ($key == $this->_selected)
					{
						XmlUtil::AddAttribute($node, "selected", "yes");
					}
					XmlUtil::AddTextNode($node, $value);
					break;
				}
				case EasyListType::UNORDEREDLIST:
				{
					XmlUtil::CreateChild($nodeWorking, "li", $value);
					break;
				}
			}
		}
		
	}
514668
public function onFieldDataSave($currentValue, array $fieldData)
    {
        if ((null === $currentValue) ||
                ($currentValue instanceof \Zend_Db_Expr) ||
                \MUtil_String::startsWith($currentValue, 'current_', true)) {
            return $currentValue;
        }

        $saveFormat = $this->getStorageFormat();

        if ($currentValue instanceof \Zend_Date) {
            return $currentValue->toString($saveFormat);

        } else {
            $displayFormat = $this->getDateFormat();

            $saveDate = \MUtil_Date::ifDate($currentValue, array($displayFormat, $saveFormat, \Gems_Tracker::DB_DATETIME_FORMAT));
            if ($saveDate instanceof \Zend_Date) {
                return $saveDate->toString($saveFormat);
            }
        }

        return (string) $currentValue;
    }
1246934
public static function getFileFromManifest(array $config, string $fileName, string $type = 'legacy'): string
    {
        try {
            $path = self::getModuleEntry($config, $fileName, $type, true);
        } catch (NotFoundHttpException $e) {
            Craft::error($e->getMessage(), __METHOD__);
        }
        if ($path !== null) {
            $path = self::combinePaths(
                $config['localFiles']['basePath'],
                $path
            );

            return self::getFileFromUri($path, null) ?? '';
        }

        return '';
    }