Scan an addon definition file

@param string $definitionFile path to addon definition file
@return boolean
15218
protected function scanAddonDefinition($definitionFile) {
        if (!file_exists($definitionFile)) {
            throw new \Exception("missing definition file");
        }

        // Prepare addon info array
        $definition = [
            'path'      => dirname($definitionFile),
            'requires'  => []
        ];

        // Read from definition file
        $definitionData = json_decode(file_get_contents($definitionFile), true);
        if (!$definitionData) {
            throw new \Exception("failed to parse definition file");
        }
        $definition = array_merge_recursive($definition, $definitionData);

        // Check that we got everything we need
        $requiredKeys = ['name', 'description', 'author', 'version'];
        $requiredMatch = array_fill_keys($requiredKeys, null);

        $requirementCheck = array_intersect_key($definition, $requiredMatch);
        if (count($requirementCheck) < count($requiredKeys)) {
            $missing = array_diff_key($requiredMatch, $definition);
            throw new \Exception("missing definition fields (".implode(',',array_keys($missing)).")");
        }

        return $definition;
    }
146343
function isFile( $filename = false )
    {
        if ( !$filename )
            $filename = $this->FileName;
        return $this->doIsFile( $filename );
    }
397268
public function read($sConfigFile)
    {
        $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION);
        switch($sExt)
        {
        case 'php':
            $aConfigOptions = Php::read($sConfigFile);
            break;
        case 'yaml':
        case 'yml':
            $aConfigOptions = Yaml::read($sConfigFile);
            break;
        case 'json':
            $aConfigOptions = Json::read($sConfigFile);
            break;
        default:
            $sErrorMsg = jaxon_trans('config.errors.file.extension', array('path' => $sConfigFile));
            throw new \Jaxon\Config\Exception\File($sErrorMsg);
        }
        return $aConfigOptions;
    }
529302
private function resolveViewFile(string $viewFile): string
    {
        try {

            if (file_exists($viewFile)) {
                return $viewFile;
            }

            $this->checkTemplatesDirectoryExists();

            return $this->resolveTemplateFile($viewFile);

        } catch (\Exception $e) {
          throw new \RuntimeException($e->getMessage());
        } catch (\Throwable $t) {
            throw new \RuntimeException(
                sprintf(
                    'Template %s was not found. Looked in %s',
                    $viewFile,
                    implode(',', $this->templatesDirectories))
            );
        }
    }
1224390
public static function overload($envFile = ".env")
    {
        self::getLoader()->overloader = true;
        self::getLoader()->innerLoad($envFile);
    }
845115
public function addDefinition(Definition $definition)
    {
        $attribute = $definition->getAttribute();
        $key = $definition->getKey();

        $this->mongoIndex[$key] = $attribute;

        $this->definitions[$attribute] = $definition;
    }
890493
private function validateFilesPaths(array $definitionFileDirectories): bool
    {
        if (count($definitionFileDirectories) < 1) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is empty, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }

        if (array_diff(array_keys($definitionFileDirectories), $this->requiredSchemaFileKeys)) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is incomplete, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }
        foreach ($definitionFileDirectories as $key => $path) {
            if (empty($path)) {
                throw new InvalidConfigurationException(
                    sprintf(
                        'The "schema_paths" config value for key "%s" is empty, it should contain a value with a valid path',
                        $key
                    )
                );
            }

            if (! file_exists($path)) {
                throw new InvalidConfigurationException(
                    sprintf('The "schema_paths" config value for key "%s" contains a path that does not exist', $key)
                );
            }
        }

        return true;
    }
990755
public function loadFromFieldset($definition)
	{
		if(!is_array($definition))
		{
			$definition = deserialize($definition, true);
		}

		$buttons  = array();
		$group    = false;
		$dropdown = false;

		foreach($definition as $button)
		{
			if($button['label'] == '' && $button['type'] != 'group')
			{
				continue;
			}

			// encode value
			if(isset($button['button']) && $button['button'] == 'link')
			{
				if (substr($button['value'], 0, 7) == 'mailto:')
				{
					$button['value'] = \String::encodeEmail($button['value']);
				}
				else
				{
					$button['value'] = ampersand($button['value']);
				}
			}

			if($dropdown !== false && ($button['type'] != 'child' && $button['type'] != 'header'))
			{
				if($group !== false)
				{
					$this->addItemToTarget($group['items'], $dropdown);
				}
				else
				{
					$this->addItem($dropdown);
				}

				$dropdown = false;
			}

			// create new group
			if($button['type'] == 'group')
			{
				$this->toolbar = true;

				if($dropdown !== false)
				{
					if($group)
					{
						$this->addItemToTarget($group['items'], $dropdown);
					}
					else
					{
						$this->addItem($dropdown);
					}

					$dropdown = false;
				}

				if($group !== false)
				{
					$this->addItem($group);
				}

				$group = $button;
				$group['items'] = array();
			}

			// create dropdown
			elseif($button['type'] == 'dropdown')
			{
				$dropdown = $button;
				$dropdown['items'] = array();
			}

			// add dropdown child
			elseif($button['type'] == 'child' || $button['type'] == 'header')
			{
				$dropdown['items'][] = $button;
			}

			// add button
			elseif($group !== false)
			{
				$this->addItemToTarget($group['items'], $button);
			}
			else
			{
				$this->addItem($button);
			}
		}

		if($group !== false)
		{
			if($dropdown !== false)
			{
				$this->addItemToTarget($group['items'], $dropdown);
			}

			$this->addItem($group);
		}
		elseif($dropdown !== false)
		{
			$this->addItem($dropdown);
		}
	}
610603
private function _readTemplate($templateFile) {
		$filename = PHPCHECKSTYLE_HOME_DIR . "/html/template/" . $templateFile . ".tmpl";
		$handle = fopen($filename, "r");
		$contents = fread($handle, filesize($filename));
		fclose($handle);

		return $contents;
	}
676480
public function imageChange($sourceFile)
    {
        if (is_array($sourceFile)) {
            $fileName = key($sourceFile);
            $sourceFile = current($sourceFile);
        } else {
            $fileName = $sourceFile;
        }
        if (!file_exists($sourceFile)) {
            return false;
        }
        $imageName = $this->imageAttribute . '_' .
            md5(implode('-', (array)$this->owner->getPrimaryKey()) . microtime(true) . rand()) .
            '.' . pathinfo($fileName)['extension'];
        $destinationFile = $this->getImageAbsolutePath() . '/' . $imageName;
        if (!copy($sourceFile, $destinationFile)) {
            return false;
        }
        $this->imageRemoveFile();
        if (!empty($this->imageSize)) {
            $size = $this->imageSize;
            if (!is_array($size)) {
                $size = [$size, $size];
            }
            $newBox = new Box($size[0], $size[1]);
            $image = (new Transformation())->thumbnail(
                $newBox,
                $this->imageResizeStrategy == self::CROP ?
                    ImageInterface::THUMBNAIL_OUTBOUND : ImageInterface::THUMBNAIL_INSET
            )->apply(yii\imagine\Image::getImagine()->open($destinationFile));
            $currentBox = $image->getSize();
            if ($this->imageResizeStrategy === self::FRAME) {
                if ($this->imageFrameColor === self::COLOR_TRANSPARENT) {
                    $frameColor = '#fff';
                    $alpha = 100;
                } else {
                    $frameColor = $this->imageFrameColor;
                    $alpha = 0;
                }
                $image = (new Transformation())->add(
                    new Canvas(
                        yii\imagine\Image::getImagine(),
                        $newBox,
                        $size[0] == $currentBox->getWidth() ?
                            new Point(0, ($size[1] - $currentBox->getHeight()) / 2) :
                            new Point(($size[0] - $currentBox->getWidth()) / 2, 0),
                        new Color($frameColor, $alpha)
                    )
                )->apply($image);
            }
            $image->save($destinationFile);
        }
        $this->owner->setAttribute($this->imageAttribute, $imageName);
        $this->owner->updateAttributes([$this->imageAttribute]);
        return true;
    }
1006318
public function appendTiff($appendFile = "")
    {
        //check whether file is set or not
        if ($appendFile == '')
            throw new Exception('No file name specified');

        $strURI = Product::$baseProductUri . '/imaging/tiff/' . $this->getFileName() . '/appendTiff?appendFile=' . $appendFile;

        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'POST', '', '');

        $json = json_decode($responseStream);

        if ($json->Status == 'OK') {
            $folder = new Folder();
            $outputStream = $folder->getFile($this->getFileName());
            $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
            Utils::saveFile($outputStream, $outputPath);
            return $outputPath;
        } else {
            return false;
        }
    }
1067948
private function resolve($definition)
    {
        return !is_null($this->resolver) ? $this->resolver->resolve($definition) : $definition;
    }
445182
public static function getCompiledFile($inputFile)
    {
        $currentFile = self::fixPathForInput($inputFile);
        $pathInfo = pathinfo($currentFile);
        $parser = \KayStrobach\Dyncss\Configuration\BeRegistry::get()->getFileHandler($pathInfo['extension']);
        if ($parser !== null) {
            $parser->setOverrides(self::getOverrides());
            $outputFile = $parser->compileFile($currentFile);

            return self::fixPathForOutput($outputFile);
        } else {
            return $inputFile;
        }
    }
1013832
function templateFile( $templateName )
    {
        if ( isset( $this->Templates[$templateName] ) )
        {
            return $this->Templates[$templateName]['filepath'];
        }
        return false;
    }
313640
protected function isProvider(File $phpCsFile): bool
    {
        return $this->hasCorrectName($phpCsFile, 'DependencyProvider') && $this->isCoreProvider($phpCsFile);
    }
1109811
public function resolve($pathOrFile)
    {
        if (is_dir($pathOrFile)) {
            $pathOrFile .= DIRECTORY_SEPARATOR . '.docheader';
        }

        if (! is_file($pathOrFile)) {
            throw DocHeaderFileConfiguration::notFound($pathOrFile);
        }

        return $pathOrFile;
    }
893118
public static function mapExtensionToType($dataFile) {
        $ext = substr(strrchr($dataFile, '.'), 1);
        $ext = strtolower($ext);
        switch ($ext) {
            case 'xls':
            case 'xlsx':
                return 'Excel';
            break;
            case 'json':
                return 'Json';
            break;
            default:
                throw new Garp_Content_Import_Exception("Could not find importer for type $ext");
            break;
        }
    }