Check if a file version should be processed (it must be an SVG image).

{@inheritdoc}

@see \Concrete\Core\File\ImportProcessor\ProcessorInterface::shouldProcess()
182368
public function shouldProcess(Version $version)
    {
        $versionTypeObject = $version->getTypeObject();

        return $versionTypeObject->getGenericType() == Type::T_IMAGE && $versionTypeObject->isSVG();
    }
909277
public static function isImage($file)
    {
        if (!$v = getimagesize($file)) {
            return false;
        }
        return in_array($v[2], [IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP]);
    }
332038
function shouldProcess (filePath, done) {
        done(!!multimatch(filePath, transform.pattern, transform.opts).length)
      }
234485
public function check()
    {
        $result = false;

        $version = $this->dataService->getVersion();

        // Check the version. If this is > 0 then it seems to be a version number like 1.2.3
        // Because the getVersion method can return an error like
        //      Warning: Identity file /Users/agrunwald/.ssh/id_rsa_config not accessible: No such file or directory.
        //      Permission denied (publickey).
        //
        if ($version && version_compare($version, 0, '>')) {
            $this->version = $version;
            $result = true;
        }

        return $result;
    }
1127373
public function canProcessRequest()
    {
        // Check the validity of the function name
        if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
        {
            $this->sRequestedFunction = null;
        }
        return ($this->sRequestedFunction != null);
    }
915889
public static function isProcessing( eZContentObjectVersion $versionObject )
    {
        $count = parent::count(
            self::definition(),
            array(
                'ezcontentobject_version_id' => $versionObject->attribute( 'id' ),
                // 'status' => self::STATUS_WORKING // not used yet
            )
        );
        return ( $count != 0 );
    }
155666
protected function process()
    {

        // query whether or not we've the flag to upload the image files has been set
        if ($this->getSubject()->getConfiguration()->hasParam(ConfigurationKeys::COPY_IMAGES)) {
            // query whether or not we've to upload the image files
            if ($this->getSubject()->getConfiguration()->getParam(ConfigurationKeys::COPY_IMAGES)) {
                // initialize the array for the actual images
                $actualImageNames = array();

                // iterate over the available image fields
                foreach (array_keys($this->getImageTypes()) as $imageColumnName) {
                    // do nothing if the column is empty
                    if (!$this->hasValue($imageColumnName)) {
                        continue;
                    }

                    // override the image path with the new one, if the image has already been processed
                    if (isset($actualImageNames[$imageName = $this->getValue($imageColumnName)])) {
                        $this->setValue($imageColumnName, $actualImageNames[$imageName]);
                        continue;
                    }

                    // upload the file and set the new image path
                    $imagePath = $this->getSubject()->uploadFile($imageName);

                    // log a message that the image has been copied
                    $this->getSubject()
                         ->getSystemLogger()
                         ->debug(
                             sprintf(
                                 'Successfully copied image type %s with name %s => %s',
                                 $imageColumnName,
                                 $imageName,
                                 $imagePath
                             )
                         );

                    // override the image path with the new one
                    $this->setValue($imageColumnName, $imagePath);

                        // add the image to the list with processed images
                    $actualImageNames[$imageName] = $imagePath;
                }

                // query whether or not, we've additional images
                if ($additionalImages = $this->getValue(ColumnKeys::ADDITIONAL_IMAGES, null, array($this, 'explode'))) {
                    // process all the additional images
                    foreach ($additionalImages as $key => $additionalImageName) {
                        // query whether or not the image has already been processed
                        if (isset($actualImageNames[$additionalImageName])) {
                            // if yes, override the image path
                            $additionalImages[$key] = $imagePath;
                            // and override the image path with the new one
                            $this->setValue($imageColumnName, $actualImageNames[$additionalImageName]);
                            continue;
                        }

                        // upload the file and set the new image path
                        $imagePath = $this->getSubject()->uploadFile($additionalImageName);

                        // log a message that the image has been copied
                        $this->getSubject()
                             ->getSystemLogger()
                             ->debug(
                                 sprintf(
                                     'Successfully copied additional image wth name %s => %s',
                                     $additionalImageName,
                                     $imagePath
                                 )
                             );

                        // override the image path
                        $additionalImages[$key] = $imagePath;

                        // add the image to the list with processed images
                        $actualImageNames[$additionalImageName] = $imagePath;
                    }

                    // override the image paths with the new one
                    $this->setValue(ColumnKeys::ADDITIONAL_IMAGES, implode(',', $additionalImages));
                }
            }
        }
    }
289846
protected function shouldAttachmentBeCal()
    {
        $browser = $this->getUserAgent();

        $matches = [];
        preg_match('/os (\d+)_(\d+)\s+/', $browser, $matches);
        $version = isset($matches[1]) ? ((int)$matches[1]) : 999;

        return ($version < 8);
    }
808504
public static function checkSystemVersion()
    {
        if (\Genesis\Utils\Common::compareVersions(self::$minPHPVersion, '<')) {
            throw new \Exception(self::getErrorMessage('system'));
        }
    }
585284
private function process($path)
    {
        $loader = $this->delegatingLoaderFactory->create($this->containerBuilder, $path);

        $servicesFile = 'services.' . $this->servicesFormat;
        $servicesTestFile = 'services_test.' . $this->servicesFormat;

        if ($this->filesystem->exists($path . '/' . $servicesFile)) {
            $loader->load($servicesFile);
        }

        if ($this->isTestEnvironment && $this->filesystem->exists($path . '/' . $servicesTestFile)) {
            $loader->load($servicesTestFile);
        }
    }
611596
function processFile($token, $file)
	{
		// Why not in one condition?
		// @see http://forum.nettephp.com/cs/viewtopic.php?pid=29556#p29556
		if (!$file instanceof FileUpload) {
			return false;
		}

		/* @var $validateCallback Callback */
		$validateCallback = MultipleFileUpload::$validateFileCallback;

		/* @var $isValid bool */
		$isValid = $validateCallback->invoke($file);

		if ($isValid) {
			MultipleFileUpload::getQueuesModel()
				->getQueue($token)
				->addFile($file);
		}
		return $isValid;
	}
834586
function hasStoredFileInformation( $object, $objectVersion, $objectLanguage )
    {
        if ( !$object )
            $object = $this->object();
        if ( $objectVersion === false )
            $objectVersion = $object->attribute( 'current_version' );
        if ( $objectLanguage === false )
            $objectLanguage = $object->attribute( 'default_language' );
        $dataType = $this->dataType();
        return $dataType->hasStoredFileInformation( $object, $objectVersion, $objectLanguage,
                                                    $this );
    }
750021
protected function determineFormat()
    {
        $formatInfo = getimagesize($this->fileName);

        // non-image files will return false
        if ($formatInfo === false) {
            if ($this->remoteImage) {
                throw new \Exception("Could not determine format of remote image: {$this->fileName}");
            } else {
                throw new \Exception("File is not a valid image: {$this->fileName}");
            }
        }

        $mimeType = isset($formatInfo['mime']) ? $formatInfo['mime'] : null;

        switch ($mimeType) {
            case 'image/gif':
                $this->format = 'GIF';
                break;
            case 'image/jpeg':
                $this->format = 'JPG';
                break;
            case 'image/png':
                $this->format = 'PNG';
                break;
            default:
                throw new \Exception("Image format not supported: {$mimeType}");
        }
    }
1224120
public function isVersioningNecessary($con = null)
    {
        if ($this->alreadyInSave) {
            return false;
        }

        if ($this->enforceVersion) {
            return true;
        }

        if (ChildIndexEngineIndexQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
            return true;
        }

        return false;
    }
735264
public function hasFile($key)
    {
        if ($this->needParser()) {
            $this->treatPutRequest();
            $files = $this->fileParser->getParsed();

            return array_key_exists($key, $files);
        }

        return parent::hasFile($key);
    }
812872
public function check($file)
    {
        $process = new Process('php -lf '.$file);
        $process->run();
        if (0===$process->getExitCode()) {
            return true;
        } else {
            //$this->logger->addFail('Check syntax failed <comment>'.$process->getOutput().'</comment>');
            throw new LinterException($this,$process->getOutput());
            //return false;
        }
    }
1083867
public function existsFile() {
		$file =$this->getPath();
		if (file_exists($file)) {
			if ($this->type == self::TYPE_ENTITY) {
				return self::FILE_MATCH;
			}
			
			$data = file_get_contents($file);
			if (strpos($data, "@version ".Version::BUILDER_VERSION) !== FALSE) {
				return self::FILE_MATCH;
			} else {
				return self::FILE_OUTDATED;
			}
		}
		return self::FILE_MISSING;
	}