Neos\Flow\ResourceManagement\PersistentResource::getFileExtension PHP 메소드

getFileExtension() 공개 메소드

Returns the file extension used for this resource
public getFileExtension ( ) : string
리턴 string The file extension used for this file
    public function getFileExtension()
    {
        $pathInfo = pathinfo($this->filename);
        return isset($pathInfo['extension']) ? $pathInfo['extension'] : '';
    }

Usage Example

예제 #1
0
 /**
  * The given $value is valid if it is an \Neos\Flow\ResourceManagement\PersistentResource of the configured resolution
  * Note: a value of NULL or empty string ('') is considered valid
  *
  * @param \Neos\Flow\ResourceManagement\PersistentResource $resource The resource object that should be validated
  * @return void
  * @api
  */
 protected function isValid($resource)
 {
     if (!$resource instanceof \Neos\Flow\ResourceManagement\PersistentResource) {
         $this->addError('The given value was not a PersistentResource instance.', 1327865587);
         return;
     }
     $fileExtension = $resource->getFileExtension();
     if ($fileExtension === null || $fileExtension === '') {
         $this->addError('The file has no file extension.', 1327865808);
         return;
     }
     if (!in_array($fileExtension, $this->options['allowedExtensions'])) {
         $this->addError('The file extension "%s" is not allowed.', 1327865764, array($resource->getFileExtension()));
         return;
     }
 }
All Usage Examples Of Neos\Flow\ResourceManagement\PersistentResource::getFileExtension