示例#1
0
 /**
  * No index action, return 404 error page
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function indexAction()
 {
     $view = new \Zend\View\Model\JsonModel([]);
     $view->setTemplate('/error/404.phtml');
     $this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_404);
     return $view;
 }
示例#2
0
    /**
     * Saves auth.json file
     *
     * @param string $username
     * @param string $password
     * @return bool
     * @throws \Exception
     */
    public function saveAuthJson($username, $password)
    {
        $authContent = [
            self::KEY_HTTPBASIC => [
                $this->getCredentialBaseUrl() => [
                    self::KEY_USERNAME => "$username",
                    self::KEY_PASSWORD => "$password"
                ]
            ]
        ];
        $json = new \Zend\View\Model\JsonModel($authContent);
        $json->setOption('prettyPrint', true);
        $jsonContent = $json->serialize();

        return $this->getDirectory()->writeFile(
            \Magento\Framework\App\Filesystem\DirectoryList::COMPOSER_HOME .
            DIRECTORY_SEPARATOR . $this->pathToAuthFile,
            $jsonContent
        );
    }