Gc\Media\Info::fromFile PHP Method

fromFile() public method

Initialize file from path
public fromFile ( string $filePath ) : boolean
$filePath string File path
return boolean
    public function fromFile($filePath)
    {
        if (!empty($filePath) and $filePath == $this->getFilename()) {
            return true;
        } elseif ($filePath != $this->getFilename() and file_exists($filePath)) {
            $this->setFilename($filePath);
            $this->setInfos($this->getReader()->fromFile($filePath));
            return true;
        }
        return false;
    }

Usage Example

コード例 #1
0
ファイル: Module.php プロジェクト: gotcms/gotcms
 /**
  * Init Module form
  *
  * @return void
  */
 public function init()
 {
     $this->setAttribute('class', 'relative');
     $fileInfo = new Info();
     $modulesInfos = array();
     $options = array('' => 'Select an option');
     foreach ($this->getServiceLocator()->get('ModulesList') as $path => $dir) {
         $options[$dir] = $dir;
         $configFile = $path . '/module.info';
         if ($fileInfo->fromFile($configFile) === true) {
             $modulesInfos[$dir] = $fileInfo->render();
         }
     }
     $collection = new ModuleCollection();
     $modules = $collection->getModules();
     foreach ($modules as $module) {
         if (in_array($module->getName(), $options)) {
             unset($options[$module->getName()]);
             unset($modulesInfos[$module->getName()]);
         }
     }
     $module = new Element\Select('module');
     $module->setLabel('Module')->setLabelAttributes(array('class' => 'required'));
     $module->setAttribute('id', 'module')->setAttribute('class', 'form-control')->setAttribute('modules_info', $modulesInfos)->setValueOptions($options);
     $this->add($module);
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('module' => array('name' => 'module', 'required' => true, 'validators' => array(array('name' => 'not_empty')))));
     $this->setInputFilter($inputFilter);
 }
All Usage Examples Of Gc\Media\Info::fromFile