/** * main * */ public function main() { $default = APP . 'Locale' . DS . 'default.pot'; $response = $this->in("What is the full path you would like to merge file (created pot file)?\nExample:" . $default . "\n[Q]uit", null, $default); if (strtoupper($response) === 'Q') { $this->out('Merge Aborted'); $this->_stop(); } $created = new File($response, false, 0755); if (!$created->exists()) { $this->err('The file path you supplied was not found. Please try again.'); $this->_stop(); } $default = APP . 'Locale' . DS . 'ja' . DS . 'default.po'; $response = $this->in("What is the full path you would like to merge file (current po file)?\nExample: " . $default . "\n[Q]uit", null, $default); if (strtoupper($response) === 'Q') { $this->out('Merge Aborted'); $this->_stop(); } $current = new File($response, false, 0755); if (!$current->exists()) { $this->err('The file path you supplied was not found. Please try again.'); $this->_stop(); } $createdTranslations = Translations::fromPoFile($created->path); $createdTranslations->addFromPoFile($current->path); $merged = $createdTranslations->toPoString(); $this->createFile($current->path, $merged); }
/** * Download an attachment realated to an article. * * @throws \Cake\Network\Exception\NotFoundException When it missing an arguments or when the file doesn't exist. * @throws \Cake\Network\Exception\ForbiddenException When the user is not premium. * * @return \Cake\Network\Exception\ForbiddenException * \Cake\Network\Exception\NotFoundException * \Cake\Network\Response */ public function download() { $this->loadModel('Users'); $user = $this->Users->find()->where(['id' => $this->request->session()->read('Auth.User.id')])->first(); if (is_null($user) || !$user->premium) { throw new ForbiddenException(); } if (!isset($this->request->type)) { throw new NotFoundException(); } switch ($this->request->type) { case "blog": $this->loadModel('BlogAttachments'); $attachment = $this->BlogAttachments->get($this->request->id); if (!$attachment) { throw new NotFoundException(); } $file = new File($attachment->url); if (!$file->exists()) { throw new NotFoundException(); } $this->response->file($file->path, ['download' => true, 'name' => $attachment->name]); $this->BlogAttachments->patchEntity($attachment, ['download' => $attachment->download + 1]); $this->BlogAttachments->save($attachment); break; default: throw new NotFoundException(); } return $this->response; }
public function afterDelete(Event $event, Banner $banner, \ArrayObject $options) { $bannerFile = new File(WWW_ROOT . 'img' . DS . $banner->image); $bannerFile->delete(); $bannerFile->close(); Cache::clear(false, 'banners_manager_cache'); }
/** * Cria um plugin de teste e o carrega para conseguir rodar os testes. */ public function setUp() { parent::setUp(); $testData = ['full_path' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS, 'config_folder' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS . 'config' . DS, 'css_folder' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS . 'webroot' . DS . '_assets' . DS . 'css' . DS, 'js_folder' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS . 'webroot' . DS . '_assets' . DS . 'js' . DS, 'img_folder' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS . 'webroot' . DS . '_assets' . DS . 'img' . DS, 'packages_folder' => ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest' . DS . 'webroot' . DS . '_assets' . DS . 'packages' . DS]; $pluginFolder = new Folder($testData['full_path'], self::CREATE_FOLDER_IF_NOT_EXISTS, self::PLUGIN_FOLDER_PERMISSIONS); $pluginFolder->create($testData['config_folder']); $pluginFolder->create($testData['css_folder']); $pluginFolder->create($testData['js_folder']); $pluginFolder->create($testData['img_folder']); $pluginFolder->create($testData['packages_folder'] . 'sample_package'); $defaultSettingsFile = new File($testData['config_folder'] . 'default_settings.php', true); $defaultSettingsFile->write("<?php \n\t\t\treturn [\n\t\t\t\t'MyApplication.Modules.ThemeInstallerTest.Settings' => \n\t\t\t\t\t['Default' => true]\n\t\t\t\t]; \n\t\t?>"); $defaultSettingsFile->close(); $file = new File($testData['css_folder'] . 'sample.css', true); $file->write('#id { }'); $file->close(); $file = new File($testData['js_folder'] . 'sample.js', true); $file->write('#id { }'); $file->close(); $file = new File($testData['packages_folder'] . 'sample_package' . DS . 'sample.css', true); $file->write('#id { }'); $file->close(); $file = new File($testData['packages_folder'] . 'sample_package' . DS . 'sample.js', true); $file->write('#id { }'); $file->close(); $bootstrapFile = new File($testData['config_folder'] . 'bootstrap.php', true); $bootstrapFile->close(); }
public function afterDelete(Event $event, PhotoThumbnail $photo, \ArrayObject $config) { if (!empty($photo->path)) { $file = new File(WWW_ROOT . 'img' . DS . $photo->path); $file->delete(); $file->close(); } }
private function removeAndCreateFolder($path) { $dir = new Folder($path); $dir->delete(); $dir->create($path); $file = new File($path . DS . 'empty'); $file->create(); }
/** * Write swagger document to filesystem. * * @param string $path Full path to the json document including filename * @param string $content Swagger content * @throws Cake\Network\Exception\InternalErrorException * @return bool */ protected static function writeSwaggerDocumentToFile($path, $content) { $fh = new File($path, true); if (!$fh->write($content)) { throw new InternalErrorException('Error writing Swagger json document to filesystem'); } return true; }
/** * Write data in json file. * * @return void */ protected function _write() { $this->_bufferActivated(); $this->_bufferLoaded(); $JSON = new JSON($this->_buffer); $file = Path::loadedFolder() . $this->_config['file']; $File = new File($file); $File->write($JSON->write()); }
public function main() { $tick_names_and_values = array(); $this->authentication(); $http = new Client(); $this->loadModel('Stocks'); $this->loadModel('Devices'); $token_file = new File("/home/demo/token/token.txt"); $token = $token_file->read(); $token_file->close(); $MyAuthObject = new OAuthObject(array("token_type" => "Bearer", "access_token" => $token)); $OptionsToast = new WNSNotificationOptions(); $OptionsToast->SetAuthorization($MyAuthObject); $OptionsToast->SetX_WNS_REQUESTFORSTATUS(X_WNS_RequestForStatus::Request); $NotifierToast = new WindowsNotificationClass($OptionsToast); $OptionsTile = new WNSNotificationOptions(); $OptionsTile->SetAuthorization($MyAuthObject); $OptionsTile->SetX_WNS_REQUESTFORSTATUS(X_WNS_RequestForStatus::Request); //NOTE: Set the Tile type $OptionsTile->SetX_WNS_TYPE(X_WNS_Type::Tile); $NotifierTile = new WindowsNotificationClass($OptionsTile); $allStocks = $this->Stocks->find('all')->toArray(); //$allStocks = $this->Stocks->find('all')->group(['Stocks.device_id'])->toArray(); //$allStocks = $this->Stocks->Devices->find()->group(['Devices.id'])->toArray(); Debugger::dump('allStocks: '); Debugger::dump($allStocks); $allStocksByDeviceId = array(); for ($i = 0; $i < sizeof($allStocks); $i++) { $actualDeviceId = $allStocks[$i]['device_id']; $added = false; for ($a = 0; $a < sizeof($allStocksByDeviceId); $a++) { if ($allStocksByDeviceId[$a]['device_id'] == $actualDeviceId) { $allStocksByDeviceId[$a]['stocks'][] = $allStocks[$i]; $added = true; } } if (!$added) { $allStocksByDeviceId[] = ['device_id' => $actualDeviceId, 'stocks' => [$allStocks[$i]]]; } } Debugger::dump('allStocksByDeviceId: '); Debugger::dump($allStocksByDeviceId); $someStocks = $this->Stocks->find()->distinct(['tick_name'])->toArray(); for ($i = 0; $i < sizeof($someStocks); $i++) { $response = $http->get('http://download.finance.yahoo.com/d/quotes?f=sl1d1t1v&s=' . $someStocks[$i]['tick_name']); $tick_name = explode(",", $response->body())[0]; $tick_names_and_values[] = [str_replace("\"", "", $tick_name), explode(",", $response->body())[1]]; } Debugger::dump('tick_names_and_values: '); Debugger::dump($tick_names_and_values); $this->sendAllStocksNotificationsInTileNotifications($NotifierTile, $tick_names_and_values, $allStocksByDeviceId); $this->checkMinMaxValuesAndSendToastNotifications($NotifierToast, $tick_names_and_values); //$stuff = implode(",", $stuff); //$now = Time::now(); //$this->createFile('/home/demo/files_created_each_minute/'.$now->i18nFormat('yyyy-MM-dd HH:mm:ss').'.txt', $stuff); }
public function afterSave(Event $event, Entity $site, \ArrayObject $options) { $sitePath = WWW_ROOT . '..' . DS . self::SITES_DIR . DS . 'site' . $site->id; $folder = new Folder(); if (!$folder->create($sitePath, 0755)) { throw new InternalErrorException('Error create site files'); } $indexHtml = new File($sitePath . DS . 'index.html', true, 0644); $indexHtml->write($site->content); }
public function del() { if ($this->request->is('ajax')) { $data = $this->request->data; $foto = $this->CategoriasFotos->findById($data['id'])->first(); if ($this->CategoriasFotos->delete($foto)) { $url = str_replace('../', '', $foto->url); $ft = new File($url); $ft->delete(); } } }
public function uploadToControllerFolderAndIdFolder($file, $controller, $model, $id) { $filefolder = '../webroot' . DS . 'files'; $tmppath = AMUploadBehavior::checkIfSubfolderExistsAndCreateIfFalseAndReturnPath($filefolder, $controller); $path = AMUploadBehavior::checkIfSubfolderExistsAndCreateIfFalseAndReturnPath($tmppath, $id); $filename = $file['name']; $tmpfile = new File($file['tmp_name']); $fullpath = $path . DS . $filename; $tmpfile->copy($fullpath); $tmpfile->close(); return $fullpath; }
/** * write serialize data. * @param bool $overwrite * @return bool */ public function write($overwrite = false) { $path = $this->getPath(); if (true === $this->writable() && false === $overwrite) { throw new ExistsFileException('exists ' . $path); } $file = new File($path); if (!$file->write($this->export())) { throw new \RuntimeException('save failed ' . $path); } return true; }
/** * startCaching method * * Cache\[optimize] images in cache folder * * @param string $optimization 'true' or 'false' * @param string $srcPath folder name for source images * @return void */ public function startCaching($optimization = 'true', $srcPath = 'src_images') { $dir = new Folder(WWW_ROOT . 'img' . DS . $srcPath); $files = $dir->findRecursive('.*\\.(jpg|jpeg|png|gif|svg)'); /* * Error handler */ if (is_null($dir->path)) { $this->error('<red_text>Source folder not exists!</red_text>'); } if ($optimization != 'true' && $optimization != 'false') { $this->error('<red_text>Arguments \'optimization\' should equal \'true\' or \'false\'</red_text>'); } /* * Caching */ $counter = 1; $countFiles = count($files); $this->out('<info>Images caching</info>'); foreach ($files as $file) { $file = new File($file); $semanticType = explode(DS, $file->Folder()->path); $semanticType = $semanticType[count($semanticType) - 1]; //get semantic type name $this->adaptiveImagesController->passiveCaching($file->path, $semanticType); $this->_io->overwrite($this->progressBar($counter, $countFiles), 0, 50); $counter++; } /* * Optimization */ if ($optimization == 'true') { $cachePath = $this->adaptiveImagesController->getCachePath(); $pluginPath = Plugin::path('AdaptiveImages'); $cacheDir = new Folder($pluginPath . 'webroot' . DS . $cachePath); $files = $cacheDir->findRecursive('.*\\.(jpg|jpeg|png|gif|svg)'); $counter = 1; $countFiles = count($files); $this->out(''); $this->out('<info>Images optimization</info>'); foreach ($files as $file) { $this->_optimizeImage($file); $this->_io->overwrite($this->progressBar($counter, $countFiles), 0, 50); $counter++; } $this->hr(); $this->out('<green_text>Caching and optimization completed!</green_text>'); } elseif ($optimization == 'false') { $this->hr(); $this->out('<green_text>Caching completed!</green_text>'); } }
/** * Delete file action. * * @return \Cake\Network\Response|void */ public function deleteFile() { $path = $this->request->query('path'); if ($this->request->is('post') && is_file($path)) { $File = new File($path); if ($File->delete()) { $this->Flash->success(__d('file_manager', 'File successfully removed')); } else { $this->Flash->success(__d('file_manager', 'An error occurred while removing a file')); } } return $this->redirect(['action' => 'browse']); }
/** * Faz uma instalação básica do plugin. * A instalação consiste em criar o arquivo de configurações do plugin no diretório apropriado. * Este método é chamado pelo método PluginStarter::load() quando necessário. * * @param string $pluginName O nome do plugin a ser instalado. * @return void */ public function install($pluginName) { $settingsFileFolder = $this->pluginInstallationFolder . $pluginName . DS; if (Plugin::loaded($pluginName)) { $defaultFile = Plugin::path($pluginName) . 'config' . DS . 'default_settings.php'; $folderHandler = new Folder(); if (!$folderHandler->cd($settingsFileFolder)) { $folderHandler->create($settingsFileFolder); } $fileHandler = new File($defaultFile); $fileHandler->copy($settingsFileFolder . 'settings.php'); $fileHandler->close(); } }
public function testInstalledPluginSettingsFileWillNotBeOverrridenOnLoad() { $starter = new PluginStarter(); $starter->load('PluginInstallerTest'); $installedSettingsFile = new File(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'PluginInstallerTest' . DS . 'settings.php'); $defaultSettingsFile = new File(ROOT . DS . 'plugins' . DS . 'PluginInstallerTest' . DS . 'config' . DS . 'default_settings.php'); $installedSettingsFile->write("<?php \n\t\t\treturn [\n\t\t\t\t'MyApplication.Modules.PluginInstallerTest.Settings' => \n\t\t\t\t\t['Default' => false]\n\t\t\t\t]; \n\t\t?>"); $installedSettingsFile->close(); $starter->load('PluginInstallerTest'); $installedSettingsFile = new File(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'PluginInstallerTest' . DS . 'settings.php'); $this->assertEquals(strcmp($installedSettingsFile->md5(), $defaultSettingsFile->md5()) === 0, false); $installedSettingsFile->close(); $defaultSettingsFile->close(); }
/** * Deletes a file for the given FileField instance. * * File name must be passes as `file` GET parameter. * * @param string $name EAV attribute name * @return void * @throws \Cake\Network\Exception\NotFoundException When invalid attribute name * is given */ public function delete($name) { $this->loadModel('Field.FieldInstances'); $instance = $this->_getInstance($name); if ($instance && !empty($this->request->query['file'])) { $file = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}", DS); $file = new File($file); $file->delete(); } $response = ''; $this->viewBuilder()->layout('ajax'); $this->title(__d('field', 'Delete File')); $this->set(compact('response')); }
public function afterDelete(Event $event, Entity $entity, $options) { $config = $this->_config; foreach ($config['fields'] as $field) { $entityField = $entity->get($field); if (!empty($entityField)) { $filePath = $config['root'] . $entityField; $file = new File($filePath, false, 755); if ($file->exists() === true) { $file->delete(); } } } }
/** * Update the applications bootstrap.php file. * * @param string $plugin Name of plugin. * @return bool If modify passed. */ protected function _modifyBootstrap($plugin) { $finder = "/\nPlugin::load\\((.|.\n|\n\\s\\s|\n\t|)+'{$plugin}'(.|.\n|)+\\);\n/"; $bootstrap = new File($this->bootstrap, false); $contents = $bootstrap->read(); if (!preg_match("@\n\\s*Plugin::loadAll@", $contents)) { $contents = preg_replace($finder, "", $contents); $bootstrap->write($contents); $this->out(''); $this->out(sprintf('%s modified', $this->bootstrap)); return true; } return false; }
public function add() { $broch = $this->request->data; if (!empty($this->request->data)) { //hacking in blank default values since there is no inputs for the following $this->request->data['location'] = ''; $this->request->data['restrict_access'] = 0; $this->request->data['max_restricted_qty'] = 0; if ($this->request->data['image']['tmp_name'] != '') { $file = new File($this->request->data['image']['tmp_name']); $filename = $this->request->data['image']['name']; $data = $file->read(); $file->close(); $file = new File(WWW_ROOT . '/img/brochures/' . $filename, true); $file->write($data); $file->close(); unset($this->request->data['image']); $image = ['filename' => $filename, 'caption' => $filename]; $image = $this->Brochures->Images->newEntity($image); if ($image = $this->Brochures->Images->save($image)) { $this->Flash->set(__('The brochure image could not be saved. Please, try again.')); } $this->request->data['image_id'] = ''; } else { $image = ''; } try { $brochure = $this->Brochures->newEntity($this->request->data, ['accessibleFields' => ['sku' => true], 'contain' => 'Images']); if ($image) { $brochure->image = $image; } if ($brochure = $this->Brochures->save($brochure)) { $this->Flash->set(__('The brochure has been saved')); // $this->_notifyWarehouse($broch); $this->redirect(array('action' => 'index')); } else { $this->Flash->set(__('The brochure could not be saved. Please, try again.')); } } catch (Exception $e) { $this->Flash->set(__('The brochure could not be saved. Please, try again.')); } } $images = $this->Brochures->Images->find('list', array('fields' => array('id', 'caption'))); //$images['0'] = "None"; $this->LoadModel('Suppliers'); $suppliers = $this->Suppliers->find('list', ['fields' => array('company', 'id'), 'order' => ['Suppliers.company']]); //$suppliers['0'] = "None"; $this->set(compact('images', 'suppliers')); }
/** * Compare the result to the contents of the file * * @param string $path partial path to test comparison file * @param string $result test result as a string * @return void */ public function assertSameAsFile($path, $result) { if (!file_exists($path)) { $path = $this->_compareBasePath . $path; } if ($this->_updateComparisons === null) { $this->_updateComparisons = env('UPDATE_TEST_COMPARISON_FILES'); } if ($this->_updateComparisons) { $file = new File($path, true); $file->write($result); } $expected = file_get_contents($path); $this->assertTextEquals($expected, $result); }
public function upload() { $evidence = $this->Evidences->newEntity(); require_once ROOT . DS . 'vendor' . DS . 'blueimp' . DS . 'jquery-file-upload' . DS . 'server' . DS . 'php' . DS . 'UploadHandler.php'; // for greater max_file_size, // sudo vim /etc/php5/cli/php.ini // change // upload_max_filesize = 1024M // post_max_size = 1024M $options = array('upload_dir' => WWW_ROOT . 'files' . DS, 'accept_file_types' => '/\\.(gif|jpe?g|png|txt|pdf|doc|docx|xls|xlsx|ppt|pptx|rar|zip|odt|tar|gz)$/i'); $upload_handler = new UploadHandler($options); $file = new File(WWW_ROOT . 'files' . DS . $upload_handler->get_file_name_param); $file->copy(WWW_ROOT . 'files' . DS . '1.pdf', true); exit; }
/** * Edit an attachment. * * @return \Cake\Network\Response|void */ public function edit() { $this->loadModel('BlogAttachments'); $this->loadModel('BlogArticles'); $attachment = $this->BlogAttachments->find()->where(['id' => $this->request->id])->first(); //Check if the attachment is found. if (empty($attachment)) { $this->Flash->error(__d('admin', 'This attachment doesn\'t exist or has been deleted.')); return $this->redirect(['action' => 'index']); } if ($this->request->is(['put', 'post'])) { $this->BlogAttachments->patchEntity($attachment, $this->request->data()); //Check if the article has already an attachment $article = $this->BlogArticles->find()->contain(['BlogAttachments'])->where(['BlogArticles.id' => $this->request->data['article_id']])->first(); if (!is_null($article->blog_attachment) && $article->blog_attachment->id != $this->request->id) { $this->Flash->error(__d('admin', 'This article has already an attachment, you can edit it <a href="{0}" class="btn btn-sm btn-danger">here</a>.', Router::url(['_name' => 'attachments-edit', 'id' => $article->blog_attachment->id]))); return $this->redirect(['action' => 'index']); } $attachment->user_id = $this->Auth->user('id'); $attachment->accessible('url_file', true); if ($editedAttachment = $this->BlogAttachments->save($attachment)) { $file = new File(WWW_ROOT . $editedAttachment->url); $editedAttachment->name = $file->name; $editedAttachment->extension = '.' . $file->info()['extension']; $editedAttachment->size = $file->info()['filesize']; $this->BlogAttachments->save($editedAttachment); $this->Flash->success(__d('admin', 'Your attachment has been edited successfully !')); return $this->redirect(['action' => 'index']); } } $articles = $this->BlogAttachments->BlogArticles->find('list'); $this->set(compact('attachment', 'articles')); }
public function upload() { $response = []; foreach ($this->request->data('files') as $file) { $pluginsPhoto = $this->PluginsPhotos->newEntity(['name' => $file['name'], 'plugin_id' => 1]); $this->PluginsPhotos->save($pluginsPhoto); $folderDest = new Folder(WWW_ROOT . 'files/plugins/photos/d/'); $fileTemp = new File($file['tmp_name'], true, 0644); $fileTemp->copy($folderDest->path . $file['name']); $response[] = $folderDest->path . $file['name']; } $this->set(compact('response')); $this->set('_serialize', ['response']); echo json_encode($response); $this->autoRender = false; }
/** * Update the applications bootstrap.php file. * * @param string $plugin Name of plugin. * @param bool $hasBootstrap Whether or not bootstrap should be loaded. * @param bool $hasRoutes Whether or not routes should be loaded. * @param bool $hasAutoloader Whether or not there is an autoloader configured for * the plugin. * @return bool If modify passed. */ protected function _modifyBootstrap($plugin, $hasBootstrap, $hasRoutes, $hasAutoloader) { $bootstrap = new File($this->bootstrap, false); $contents = $bootstrap->read(); if (!preg_match("@\n\\s*Plugin::loadAll@", $contents)) { $autoloadString = $hasAutoloader ? "'autoload' => true" : ''; $bootstrapString = $hasBootstrap ? "'bootstrap' => true" : ''; $routesString = $hasRoutes ? "'routes' => true" : ''; $append = "\nPlugin::load('%s', [%s]);\n"; $options = implode(', ', array_filter([$autoloadString, $bootstrapString, $routesString])); $bootstrap->append(str_replace(', []', '', sprintf($append, $plugin, $options))); $this->out(''); $this->out(sprintf('%s modified', $this->bootstrap)); return true; } return false; }
/** * Test that js files are properly processed * * @return void */ public function testShrinkJs() { $ret = $this->Shrink->build(['base.js', 'base.coffee'], 'js'); // verify the result has the proper keys $this->assertArrayHasKey('path', $ret); $this->assertArrayHasKey('webPath', $ret); // verify we were returned a file $this->assertFileExists($ret['path']); // verify the contents $cacheFile = new File($ret['path']); $result = $cacheFile->read(); $cacheFile->delete(); $cacheFile->close(); $expectedfile = new File(WWW_ROOT . 'js/base.shrink.js'); $expect = $expectedfile->read(); $expectedfile->close(); $this->assertEquals($expect, $result); }
/** * __construct to set up all properties and call parent * * @param string $fileName to initialize Environment file */ public function __construct($fileName) { parent::__construct(Configure::read('CakePostman.environments.path') . $fileName); $environmentData = json_decode($this->read(), true); $this->environmentName = $environmentData['name']; $this->url = $environmentData['values'][0]['value']; $time = new Time($this->lastChange()); $this->created = $time->nice(); }
public function read($path) { $dir = new Folder($path); $read = $dir->read(); $result = []; foreach ($read[0] as $folder) { $info = new Folder($path . DS . $folder); $reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $folder); $data = ['name' => $folder, 'type' => 'folder', 'path' => $path . DS . $folder, 'reference' => $reference, 'extension' => 'folder', 'size' => $info->dirsize()]; $result[] = $data; } foreach ($read[1] as $file) { $info = new File($path . DS . $file, false); $reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $file); $data = ['name' => $info->info()['basename'], 'type' => 'file', 'path' => $path, 'reference' => $reference, 'extension' => $info->info()['extension'], 'size' => $info->info()['filesize']]; $result[] = $data; } return $result; }
/** * @param $path * @return mixed */ protected function get($path) { $file = new File($path); if (!$file->readable()) { if (true === $this->throws) { throw new \RuntimeException('not readable ' . $path); } return false; } $serialize = $file->read(); $ret = unserialize($serialize); if (empty($ret)) { if (true === $this->throws) { throw new \UnexpectedValueException('empty data'); } return false; } return $ret; }