Get documents

@param string $state

@return array
@throws \Exception
177809
public function getDocuments($state = 'published')
    {
        if (!in_array($state, Document::$DOCUMENT_STATES, true)) {
            throw new \RuntimeException('Unsupported document state: ' . $state);
        }
        return $this->repository->getContentRepository()->getDocumentsByPath($this->repository, '/', $state);
    }
800858
public static function getStateMessage($state)
    {
        if( !isset( self::$states[$state] ) ) {
            throw new UnknownPostgresErrorException("SQL error code `{$state}` is not known; Try the postgres manual http://www.postgresql.org/docs/9.1/static/errcodes-appendix.html. Consider updating this list if it is out of date.");
        }
        return self::$states[$state];
    }
160166
public function getAllDocuments()
    {
        $documents = ArrayList::create();

        foreach ($this->owner->DocumentSets() as $documentSet) {
            /** @var DocumentSet $documentSet */
            $documents->merge($documentSet->getDocuments());
        }
        $documents->removeDuplicates();

        return $documents;
    }
1138997
public function processAuthenticate($state, $extra = null)
    {

        if (!isset($state)) {
            return ["FAILURE"];
        }

        //If we don't already have a promise for this state, create one
        if (!isset($this->promises[$state])) {
            $deferred               = new Deferred();
            $this->promises[$state] = $deferred;
        }

        return $this->promises[$state]->promise();

    }
312694
public function getStates(): array
    {
        return [
            self::STATE_DRAFT           => 'Draft',
            self::STATE_OPEN            => 'Open',
            self::STATE_PAID_PARTIAL    => 'Partially Paid',
            self::STATE_PAID_PROCESSING => 'Paid (payments processing)',
            self::STATE_PAID            => 'Paid',
            self::STATE_WRITTEN_OFF     => 'Written Off',
            self::STATE_CANCELLED       => 'Cancelled',
        ];
    }
449799
protected function stateAttributes($state, array $attributes)
    {
        $stateAttributes = $this->states[$this->class][$state];

        if (! is_callable($stateAttributes)) {
            return $stateAttributes;
        }

        return call_user_func(
            $stateAttributes,
            $this->faker, $attributes
        );
    }
714249
public function getState($state = null)
	{
		if ($state === null) {
			$state = $this->getValue();
		}

		if (!isset($this->states[$state])) {
			return 'default';
		}

		return $this->states[$state];
	}
583573
protected function stateToString($state)
    {
        switch ($state) {
            case self::STATE_CANCEL:
                return "cancel";
            case self::STATE_COMPLETE:
                return "complete";
            case self::STATE_NOT_RUN: // a string like 'foo' matches here?
                return "not run";
            case self::STATE_TIMEOUT:
                return "timeout";
            case self::STATE_MAX_INPUTS_REACHED:
                return "max valid input attempts reached";
            default:
                throw new NodeException("Bad state for node");
        }
    }
1083115
public function execute(State $state) {
        $errors = [];
        foreach ($state->newCalls as $new) {
            $type = null;
            if ($new->class instanceof Operand\Literal) {
                $type = $new->class->value;
            } elseif ($new->class->type->type !== Type::TYPE_OBJECT) {
                $errors[] = ["Unknown class type for new call", $new];
                continue;
            } else {
                $type = $new->class->type->userType;
            }
            $name = strtolower($type);
            if (!isset($state->classResolves[$name])) {
                if (isset($state->internalTypeInfo->methods[$name])) {
                    // TODO
                } else {
                    $errors[] = ["Could not find class definition for $type", $new];
                }
                continue;
            }
            foreach ($state->classResolves[$name] as $sub => $class) {
                $constructor = $this->findConstructor($class);
                if ($constructor) {
                    // validate parameters!!!
                    $errors = array_merge($errors, $this->verifyCall($constructor, $new, $state, "{$class->name->value}::__construct"));
                }
            }
        }
        return $errors;
    }
1122264
public function setState($state)
		{
		$r = array_pop($this->states);
		array_push($this->states, $state);
		$this->state = $this->states[count($this->states) - 1];
		return $r;
		}
67586
public function serialize(UserState $state)
    {
        $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE);

        $data = file_exists($saveFile)
            ? $this->readJson($saveFile)
            : [];

        $data[$this->workshopName] = [
            'completed_exercises'   => $state->getCompletedExercises(),
            'current_exercise'      => $state->getCurrentExercise(),
        ];

        return file_put_contents($saveFile, json_encode($data));
    }
77544
public function recode_legacy_state_answer($state) {
        $answer = $state->answer;
        $resultarr = array();
        foreach (explode(',', $answer) as $pair) {
            $pairarr = explode('-', $pair);
            $questionid = $pairarr[0];
            $answerid = $pairarr[1];
            $newquestionid = $questionid ? $this->get_mappingid('question', $questionid) : 0;
            $newanswerid = $answerid ? $this->get_mappingid('question_answer', $answerid) : 0;
            $resultarr[] = implode('-', array($newquestionid, $newanswerid));
        }
        return implode(',', $resultarr);
    }
531544
public function isLanguageRequiredInUri($state = null)
    {
        if (isset($state)) {
            $this->languageRequiredInUri = (bool) $state;
        }

        return $this->languageRequiredInUri;
    }
194392
protected function getOverwriteValue($state, $overwrites)
    {
        if (is_array($overwrites) && array_key_exists($state, $overwrites)) {
            return $overwrites[$state];
        }
        return false;
    }
1074798
protected function getDocumentData($document)
    {
        if (is_array($document)) {
            $data = $document;
        } elseif ($document instanceof AbstractDocument) {
            $reflectionClass = new \ReflectionClass($document);
            $documentProperty = $reflectionClass->getParentClass()->getProperty('document');
            $documentProperty->setAccessible(true);
            $data = $documentProperty->getValue($document);
            foreach ($data as $key => &$value) {
                if ($value instanceof DocumentSerializableInterface) {
                    $value = $value->documentSerialize()->jsonSerialize();
                }
            }
        } else {
            throw new \Exception('Invalid data type, array or AbstractDocument expected');
        }

        return $data;
    }
382618
private function getMethod(State $state, $class, $method)
    {
        $refClass = $this->getClass($state, $class);

        if (!isset($refClass->methods[$method])) {
            throw new MarkupException(sprintf('method %s::%s does not exist', $class, $method));
        }

        return $refClass->methods[$method];
    }
1146706
public function getStateCandidates(int $state): array
    {
        $candidates = [];

        foreach ($this->candidates as $candidateId => $candidate) {
            if ($candidate->getState() == $state) {
                $candidates[$candidateId] = $candidate;
            }
        }

        return $candidates;
    }