Публикация ресурса\Закрытие доступа

@param   boolean $publish TRUE открыть доступ, FALSE закрыть доступ

@return  \Arhitector\Yandex\Disk\Resource\Closed|\Arhitector\Yandex\Disk\Resource\Opened
358065
public function setPublish($publish = true)
	{
		$request = 'resources/unpublish';

		if ($publish)
		{
			$request = 'resources/publish';
		}

		$response = $this->client->send(new Request($this->uri->withPath($this->uri->getPath().$request)
			->withQuery(http_build_query([
				'path' => $this->getPath()
			], null, '&')), 'PUT'));

		if ($response->getStatusCode() == 200)
		{
			$this->setContents([]);

			if ($publish && $this->has('public_key'))
			{
				return $this->client->getPublishResource($this->get('public_key'));
			}
		}

		return $this;
	}
892439
public function setPublishLanguages($publishLanguages)
    {
        $fileVersion = $this->getFileVersion();

        foreach ($publishLanguages as $locale) {
            $publishLanguage = new FileVersionPublishLanguage();
            $publishLanguage->setFileVersion($fileVersion);
            $publishLanguage->setLocale($locale);
            if (!$fileVersion->getPublishLanguages()->contains($publishLanguage)) {
                $fileVersion->addPublishLanguage($publishLanguage);
            }
        }

        return $this;
    }
155747
public function open()
    {
        if (!$this->isOpen()) {
            $this->resource = $this->createPDO($this->url);
        }
        return $this;
    }
649858
public function handlePublish(PublishEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof RoutableBehavior) {
            return;
        }

        $node = $this->documentInspector->getNode($document);

        try {
            $route = $this->createOrUpdateRoute($document, $event->getLocale());
        } catch (RouteIsNotUniqueException $exception) {
            throw new ResourceLocatorAlreadyExistsException($exception->getRoute()->getPath(), $document->getPath());
        }

        $document->setRoutePath($route->getPath());
        $this->entityManager->persist($route);

        $node->setProperty(
            $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale()),
            $route->getPath()
        );

        $propertyName = $this->getPropertyName($event->getLocale(), self::ROUTES_PROPERTY);

        // check if nodes previous generated routes exists and remove them if not
        $oldRoutes = $event->getNode()->getPropertyValueWithDefault($propertyName, []);
        $this->removeOldChildRoutes($event->getNode()->getSession(), $oldRoutes, $event->getLocale());

        $routes = [];
        if ($document instanceof ChildrenBehavior) {
            // generate new routes of children
            $routes = $this->generateChildRoutes($document, $event->getLocale());
        }

        // save the newly generated routes of children
        $event->getNode()->setProperty($propertyName, $routes);
        $this->entityManager->flush();
    }
98307
public function publish()
    {
        $contentObjectId = $this->version()->attribute( 'contentobject_id' );
        $contentObjectVersion = $this->version()->attribute( 'version' );

        // $processObject = ezpContentPublishingProcess::fetchByContentObjectVersion( $contentObjectId, $contentObjectVersion );
        $this->setStatus( self::STATUS_WORKING, true, "beginning publishing" );

        // prepare the cluster file handler for the fork
        eZClusterFileHandler::preFork();

        $pid = pcntl_fork();

        // force the DB connection closed
        $db = eZDB::instance();
        $db->close();
        $db = null;
        eZDB::setInstance( null );

        // Force the new stack DB connection closed as well
        try
        {
            $kernel = ezpKernel::instance();
            if ( $kernel->hasServiceContainer() )
            {
                $serviceContainer = $kernel->getServiceContainer();
                $dbHandler = $serviceContainer->get( 'ezpublish.connection' );
                $factory = $serviceContainer->get( 'ezpublish.api.storage_engine.legacy.dbhandler.factory' );
                $dbHandler->setDbHandler(
                    $factory->buildLegacyDbHandler()->getDbHandler()
                );
            }
        }
        catch ( LogicException $e )
        {
            // we just ignore this, since it means that we are running in a pure legacy context
        }

        // Force the cluster DB connection closed if the cluster handler is DB based
        $cluster = eZClusterFileHandler::instance();

        // error, cancel
        if ( $pid == -1 )
        {
            $this->setStatus( self::STATUS_PENDING, true, "pcntl_fork() failed" );
            return false;
        }
        else if ( $pid )
        {
            return $pid;
        }

        // child process
        try
        {
            $myPid = getmypid();
            pcntl_signal( SIGCHLD, SIG_IGN );

            $this->setAttribute( 'pid', $myPid );
            $this->setAttribute( 'started', time() );
            $this->store( array( 'pid', 'started' ) );

            // login the version's creator to make sure publishing happens as if ran synchronously
            $creatorId = $this->version()->attribute( 'creator_id' );
            $creator = eZUser::fetch( $creatorId );
            eZUser::setCurrentlyLoggedInUser( $creator, $creatorId );
            unset( $creator, $creatorId );

            $operationResult = eZOperationHandler::execute( 'content', 'publish',
                array( 'object_id' => $contentObjectId, 'version' => $contentObjectVersion  )
            );

            // Statuses other than CONTINUE require special handling
            if ( $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE )
            {
                if ( $operationResult['status'] == eZModuleOperationInfo::STATUS_HALTED )
                {
                    // deferred to crontab
                    if ( strpos( $operationResult['result']['content'], 'Deffered to cron' ) !== false )
                        $processStatus = self::STATUS_DEFERRED;
                    else
                        $processStatus = self::STATUS_UNKNOWN;
                }
                else
                {
                    $processStatus = self::STATUS_UNKNOWN;
                }
            }
            else
            {
                $processStatus = self::STATUS_FINISHED;
            }

            // mark the process as completed
            $this->setAttribute( 'pid', 0 );
            $this->setStatus( $processStatus, false, "publishing operation finished" );
            $this->setAttribute( 'finished', time() );
            $this->store( array( 'status', 'finished', 'pid' ) );

            // Call the postProcessing hook
            ezpContentPublishingQueue::signals()->emit( 'postHandling', $contentObjectId, $contentObjectVersion, $processStatus );
        }
        catch( eZDBException $e )
        {
            $this->reset( "database error: " . $e->getMessage() );
        }

        // generate static cache
        $ini = eZINI::instance();
        if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
        {
            $staticCacheHandlerClassName = $ini->variable( 'ContentSettings', 'StaticCacheHandler' );
            $staticCacheHandlerClassName::executeActions();
        }

        eZScript::instance()->shutdown();
        exit;
    }
1032980
public function automaticPublishUp($data)
	{
		if (!isset($data['publish_up']))
		{
			$data['publish_up'] = null;
		}

		$publish_up = $data['publish_up'];

		if (!$publish_up || $publish_up == '0000-00-00 00:00:00')
		{
			$publish_up = ($data['id'] ? $this->created : Date::of('now')->toSql());
		}

		return $publish_up;
	}
523236
public function publish(Source $source)
    {
        return (new Pipeline($this->app))
            ->send($source)
            ->through($this->publishers)
            ->then(function (Source $source) {
                if ($source->isDir()) {
                    $this->build($source->getPathname(), $source->getOutputPathname());
                }
            });
    }
104260
public function publish($override = false)
    {
        // publish files
        foreach ($this->publishAssets['files'] as $from => $to) {
            $this->publishFile($from, $to, $override);
        }

        // publish directory
        foreach ($this->publishAssets['dirs'] as $fromDir => $toDir) {
            $this->publishDir($fromDir, $toDir, $override);
        }

        // no define asset to publish, will publish source-path to publish-path
        if (!$this->hasAssetToPublish()) {
            $this->publishDir($this->sourcePath, $this->publishPath, $override);
        }

        return $this;
    }
1151521
public function doPublish($data, $form)
    {
        /** @var Versioned|RecursivePublishable|DataObject $record */
        $record = $this->getRecord();
        $isNewRecord = $record->ID == 0;

        // Check permission
        if (!$record->canPublish()) {
            return $this->httpError(403);
        }

        // Initial save and reload
        $record = $this->saveFormIntoRecord($data, $form);
        $record->publishRecursive();

        $editURL = $this->Link('edit');
        $xmlTitle = Convert::raw2xml($record->Title);
        $link = "<a href=\"{$editURL}\">{$xmlTitle}</a>";
        $message = _t(
            __CLASS__ . '.Published',
            'Published {name} {link}',
            [
                'name' => $record->i18n_singular_name(),
                'link' => $link
            ]
        );
        $this->setFormMessage($form, $message);

        return $this->redirectAfterSave($isNewRecord);
    }
893438
public function select($source) {
		$relation = $this->getFileName($source->get_relation());
		// for tree checks relation id and forms absolute path
		if ($relation == '0') {
			$relation = '';
		} else {
			$path = $source->get_source();
		}
		$path = $source->get_source();
		$path = $this->getFileName($path);
		$path = realpath($path);
		if ($path == false) {
			return new FileSystemResult();
		}
		
		if (strpos(realpath($path.'/'.$relation), $path) !== 0) {
			return new FileSystemResult();
		}
		// gets files and directories list
		$res = $this->getFilesList($path, $relation);
		// sorts list
		$res = $res->sort($source->get_sort_by(), $this->config->data);
		return $res;
	}
947825
public function pullCommand(string $directory = null, bool $publish = false, bool $database = false, bool $migrate = false, bool $flush = false, bool $dryRun = false, string $configuration = '.platform.app.yaml', string $environment = 'master', bool $yes = false)
    {
        $this->askForUserAgreement($yes, '<info>Are you sure, all local data will be deleted ?</info> (yes|<b>no</b>) ', '<b>platform.sh -> Local</b>');

        $shellConfiguration = $this->shellConfiguration('pull');
        $platformConfiguration = $this->platformConfiguration($configuration);

        if ($database) {
            $this->database($shellConfiguration, $environment, $dryRun);
        }
        if ($migrate) {
            $this->migrate($shellConfiguration, $environment, $dryRun);
        }
        if ($directory) {
            $this->rsync($directory, $shellConfiguration, $platformConfiguration, $environment, $dryRun);
        }
        if ($publish) {
            $this->publish($shellConfiguration, $environment, $dryRun);
        }
        if ($flush) {
            $this->flush($shellConfiguration, $environment, $dryRun);
        }
    }
634069
public function closeBuild(Build\Build $build)
    {
        $uuid = $build->getUuid();

        $content = json_encode(['closed' => true]);
        $this->sendHttpRequest($this->config->getEndpoint().'/api/v2/builds/'.$uuid, 'PUT', array('content' => $content), array('Content-Type: application/json'));

        return $this->getBuildReport($uuid);
    }
1251196
public function publish(Listener $listener, array $input)
    {
        $queues = $this->publisher->queued();

        try {
            $this->publisher->connect($input);
        } catch (ServerException $e) {
            Log::emergency($e);
            $this->session->forget('antares.ftp');

            return $listener->publishingHasFailed(['error' => $e->getMessage()]);
        }

        $this->session->put('antares.ftp', $input);

        if ($this->publisher->connected() && !empty($queues)) {
            $this->publisher->execute();
        }

        return $listener->publishingHasSucceed();
    }
1238629
private function cmdPublish($args)
    {
        $cmd = new PublishCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
1415
public static function getParentMenu($publish=null, $parent=null, $type=null) 
	{		
		$criteria=new CDbCriteria;
		if($publish != null)
			$criteria->compare('t.publish',$publish);
		if($parent != null)
			$criteria->compare('t.parent_id',$parent);
		
		$model = self::model()->findAll($criteria);

		if($type == null) {
			$items = array();
			if($model != null) {
				foreach($model as $key => $val) {
					$items[$val->id] = $val->title->message;
				}
				return $items;
			} else {
				return false;
			}
		} else
			return $model;
	}
764389
public function putAction( $resource )
	{
		$response = $this->createAdmin( $resource )->put( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
537498
public function releaseRepo($release = null)
    {
        $release = $this->take('version')->getRelease($release);
        $notes = $this->take('chkipper')->getReleaseNotes();
        $wait = $this->waitPush();
        if ($wait) {
            return $wait;
        }

        return $this->request('POST', '/repos/' . $this->getFull_name() . '/releases', [
            'tag_name'  => $release,
            'name'      => $release,
            'body'      => $notes,
        ]);
    }