Bolt\Translation\TranslationFile::isWriteAllowed PHP Метод

isWriteAllowed() публичный Метод

Checks if translations file is allowed to write to.
public isWriteAllowed ( ) : boolean
Результат boolean
    public function isWriteAllowed()
    {
        $msgRepl = ['%s' => $this->relPath];
        // No file, directory not writable
        if (!file_exists($this->absPath) && (!is_writable(dirname($this->absPath)) && !is_writable(dirname(dirname($this->absPath))))) {
            $msg = Trans::__("The translations file '%s' can't be created. You will have to use your own editor to make modifications to this file.", $msgRepl);
            $this->app['logger.flash']->warning($msg);
            // Have a file, but not writable
        } elseif (file_exists($this->absPath) && !is_writable($this->absPath)) {
            $msg = Trans::__('general.phrase.file-not-writable', $msgRepl);
            $this->app['logger.flash']->warning($msg);
            // File is not readable: abort
        } elseif (file_exists($this->absPath) && !is_readable($this->absPath)) {
            $msg = Trans::__('general.phrase.error-translation-file-not-readable', $msgRepl);
            $this->app->abort(Response::HTTP_NOT_FOUND, $msg);
            // File is writeable
        } else {
            return true;
        }
        return false;
    }

Usage Example

Пример #1
0
 public function testIsWriteAllowed()
 {
     $app = $this->getApp();
     $tr = new TranslationFile($app, 'translations', 'en_GB');
     $this->assertTrue($tr->isWriteAllowed());
 }
All Usage Examples Of Bolt\Translation\TranslationFile::isWriteAllowed