isDirectory()) { $result[] = new FlashMessage( 'Directory ' . $this->getRelativePathBelowSiteRoot() . ' should be a directory or link,' . ' but is of type ' . filetype($this->getAbsolutePath()), $this->getRelativePathBelowSiteRoot() . ' is not a directory', ContextualFeedbackSeverity::ERROR ); } elseif (!$this->isWritable()) { $result[] = new FlashMessage( 'Path ' . $this->getAbsolutePath() . ' exists, but no file underneath it' . ' can be created.', 'Directory ' . $this->getRelativePathBelowSiteRoot() . ' is not writable', ContextualFeedbackSeverity::ERROR ); } elseif (!$this->isPermissionCorrect()) { $result[] = new FlashMessage( 'Default configured permissions are ' . $this->getTargetPermission() . ' but current permissions are ' . $this->getCurrentPermission(), 'Directory ' . $this->getRelativePathBelowSiteRoot() . ' permissions mismatch', ContextualFeedbackSeverity::NOTICE ); } else { if ($this->isLink()) { $result[] = new FlashMessage( 'Is a link to a directory with the configured permissions of ' . $this->getTargetPermission(), 'Link ' . $this->getRelativePathBelowSiteRoot() ); } else { $result[] = new FlashMessage( 'Is a directory with the configured permissions of ' . $this->getTargetPermission(), 'Directory ' . $this->getRelativePathBelowSiteRoot() ); } } return $result; } /** * Checks if node is a directory or link * * @return bool True if node is a directory */ protected function isDirectory() { $path = $this->getAbsolutePath(); return $this->isLink() || @is_dir($path); } private function isLink(): bool { $path = $this->getAbsolutePath(); return @is_link($path) && @is_dir(realpath($path)); } }