@param bool $asResource

@return resource|string
@throws \LogicException When using the resource twice times.
969321
public function getContent($asResource = false)
    {
        static $content;

        if (false === $content || (true === $asResource && null !== $content)) {
            throw new \LogicException('resource can only be returned once');
        }

        if (true === $asResource) {
            $content = false;

            return fopen('php://input', 'rb');
        }

        if (null === $content) {
            $content = file_get_contents('php://input');
        }

        return $content;
    }
321841
public function getSoftProperties(Bool $asObject=false)
	{
		if ($asObject == true) {
			return (Object) $this->softProperties;
		}

		return $this->softProperties;
	}
1236978
public static function resource($path, $dest, $force = false)
    {
        $debug = Config::getParam('debug');
        $domains = Template::getDomains(true);
        $filenamePath = self::extractPathname($path, $domains);
        \PSFS\Services\GeneratorService::copyResources($dest, $force, $filenamePath, $debug);
        return '';
    }
414391
public function get($delimit = true)
	{
		// If there are still open delimiters throw an exception
		if ($this->openDelimiters !== 0)
		{
			throw new \LogicException('A delimiter has not been closed!');
		}

		$expression = $this->expression;

		if ($delimit)
		{
			$expression = '/' . $expression . '/'  . $this->flags;
		}

		return $expression;
	}
421875
public static function findClassFileUsingPsr(string $class): string
    {
        $classLoader = self::classLoader();
        $originalClassMap = $classLoader->getClassMap();
        $classMap = &Objects::getPropertyValue($classLoader, 'classMap', ClassLoader::class);
        $classMap = [];

        if (!$file = self::classLoader()->findFile($class)) {
            throw new \LogicException(sprintf('The class "%s" file was not found.', $class));
        }

        $classMap = $originalClassMap;

        return $file;
    }
1133177
private function createResource($resourceName)
    {
        foreach ($this->handlers as $handler) {
            if (!$handler->supports($resourceName)) {
                continue;
            }

            return $handler->createResource($resourceName);
        }

        throw new \LogicException(sprintf('No handler found for resource "%s".', $resourceName));
    }
845328
private function parseResource(array $modes, &$resource, &$root, $fullPropertyPath = '')
    {
        foreach ($modes as $relation => $mode) {
            $modeResolver = $this->resolveMode($mode);

            $steps = explode('.', $relation);

            // Get the first resource in the relation
            // TODO: Refactor
            $property = array_shift($steps);
            if (is_array($resource)) {
                if ($resource[$property] === null) {
                    continue;
                }

                $object = &$resource[$property];
            } else {
                if ($resource->{$property} === null) {
                    continue;
                }

                $object = &$resource->{$property};
            }

            if (empty($steps)) {
                // This is the deepest level. Resolve it.
                $fullPropertyPath .= $relation;
                $object = $this->modeResolvers[$mode]->resolve($relation, $object, $root, $fullPropertyPath);
            } else {
                // More levels exist in this relation.
                // We want a drill down and resolve the deepest level first.

                $path = implode('.', $steps);
                $modes = [
                    $path => $mode
                ];

                // Add the previous levels to the full path so it can be used
                // to populate the root level properly.
                $fullPropertyPath .= $property . '.';

                if (Utility::isCollection($object)) {
                    $object = $this->parseCollection($modes, $object, $root, $fullPropertyPath);
                } else {
                    $object = $this->parseResource($modes, $object, $root, $fullPropertyPath);
                }
            }

            // Reset the full property path after running a full relation
            $fullPropertyPath = '';
            Utility::setProperty($resource, $property, $object);
        }

        return $resource;
    }
1112098
public function resource()
    {
        if (!is_resource($this->value)) {
            throw new InvalidResourceException($this->name, $this->value);
        }

        return $this;
    }
1096544
public function createForm (bool $edit = false)
    {
        $form = [
            'storageURL' => route ('admin.api.resources'),
            'buttons'    => [
                [
                    "class" => "col-centered",
                    "label" => trans ('HCTranslations::core.buttons.submit'),
                    "type"  => "submit",
                ],
            ],
            'structure'  => [[
                "type"            => "resource",
                "fieldID"         => "resource",
                "uploadURL"       => route("admin.api.resources"),
                "viewURL"         => route("resource.get", ['/']),
                "label"           => trans ("HCResources::resources.resource"),
                "required"        => 1,
                "requiredVisible" => 1,
            ]],
        ];

        if (!$edit)
            return $form;

        //Make changes to edit form if needed
        $form['structure'] = [[
            "type"            => "singleLine",
            "fieldID"         => "original_name",
            "label"           => trans ("HCResources::resources.original_name"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "id",
            "label"           => trans ("HCResources::resources.safe_name"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "size",
            "label"           => trans ("HCResources::resources.size"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "path",
            "label"           => trans ("HCResources::resources.path"),
            "readonly"        => 1,
        ]];

        return $form;
    }
1033283
public function getProviderInstance($providerOrClass)
    {
        if (is_a($providerOrClass, ProviderAbstract::PROVIDER_CLASS, true)) {
            if (!is_object($providerOrClass)) {
                $providerOrClass = new $providerOrClass;
            }
            return $providerOrClass;
        } else {
            throw new LogicException(
                Message::get(Message::EXT_PROVIDER_ERROR, $providerOrClass),
                Message::EXT_PROVIDER_ERROR
            );
        }
    }
469525
protected function __toSend($asDomElement = false)
    {
        $this->setValue([
            $this->getCreated(),
            $this->getExpires(),
        ]);

        return parent::__toSend($asDomElement);
    }
239455
public function get($id, $loadResource = true)
	{
		$contain = array('LogDetail');

		if (!empty(AuditableConfig::$responsibleModel)) {
			$this->bindModel(array(
				'belongsTo' => array(
					'Responsible' => array(
						'className' => AuditableConfig::$responsibleModel,
						'foreignKey' => 'responsible_id'
						)
					)
				)
			);

			$contain[] = 'Responsible';
		}

		$data = $this->find('first', array(
			'conditions' => array('Logger.id' => $id),
			'contain' => $contain
			)
		);

		$linked = null;

		if ($loadResource) {
			$Resource = ClassRegistry::init($data[$this->alias]['model_alias']);

			$linked = $Resource->find('first', array(
				'conditions' => array('id' => $data[$this->alias]['model_id']),
				'recursive' => -1
				)
			);
		}

		if (!empty($linked)) {
			$data[$Resource->alias] = $linked[$Resource->alias];
		}

		if (array_search('Responsible', $contain) === false) {
			$data['Responsible'] = array();
		}

		if (isset($this->Responsible) && empty($data['Responsible'][$this->Responsible->primaryKey])) {
			$data['Responsible'] = array();
		}

		return $data;
	}
942088
protected function __toSend($asDomElement = false)
    {
        /**
         * Create element tag.
         */
        $element = self::getDom()->createElement($this->getNamespacedName());
        $element->setAttributeNS('http://www.w3.org/2000/xmlns/', sprintf('xmlns:%s', $this->getNamespacePrefix()), $this->getNamespace());
        /*
         * Define element value
         * Add attributes if there are any
         */
        $this
            ->appendValueToElementToSend($this->getValue(), $element)
            ->appendAttributesToElementToSend($element)
        ;
        // Returns element content
        if ($asDomElement) {
            return $element;
        }

        return self::getDom()->saveXML($element);
    }
327219
private function getResourceBundle($locale)
    {
        if (!isset($this->resourceBundles[$locale])) {
            $resourceBundle = \ResourceBundle::create($locale, $this->resourcesDirectory, true);

            if ($resourceBundle === null) {
                throw new \IntlException('Could not create resource bundle');
            }

            $this->resourceBundles[$locale] = $resourceBundle;
        }

        return $this->resourceBundles[$locale];
    }
674945
public function process(ContainerBuilder $container)
    {
        $tagged_services = $container->findTaggedServiceIds('asf_core.manager');

        foreach ($tagged_services as $id => $tags) {
            foreach ($tags as $attributes) {
                if (!isset($attributes['entity'])) {
                    throw new \LogicException(sprintf('Attribute "entity" missing for service tagged "asf_core.manager" for service id "%s"', $id));
                }

                $class = false !== strpos($container->getDefinition($id)->getClass(), '%') ? $container->getParameter($this->translateParameter($container->getDefinition($id)->getClass())) : $container->getDefinition($id)->getClass();
                $entity = false !== strpos($attributes['entity'], '%') ? $container->getParameter($this->translateParameter($attributes['entity'])) : $attributes['entity'];

                if (!class_exists($class)) {
                    $container->getDefinition($id)->setClass('ASF\CoreBundle\Utils\Manager\ASFManager');
                }

                $arguments = $container->getDefinition($id)->getArguments();
                $injected_args = array(
                    new Reference('doctrine.orm.entity_manager'),
                    $entity,
                );

                $container->getDefinition($id)->setArguments(array_merge($injected_args, $arguments));
            }
        }
    }
831175
final protected function getRequiredString(array $values, string $name, bool $isFirst = false) : string
    {
        $value = $this->getOptionalString($values, $name, $isFirst);

        if ($value === null) {
            throw new \LogicException(sprintf(
                'Attribute "%s" of annotation %s is required.',
                $name,
                $this->getAnnotationName()
            ));
        }

        return $value;
    }
1126784
public function getAsciiContentPath(string $resource)
    {
        if (null === $this->container->getParameter('ascii')) {
            return null;
        }

        $paths = $this->container->getParameter('ascii');
        if (!array_key_exists($resource, $paths)) {
            return null;
        }

        // Deal with multiple ascii files by returning one at random.
        if (\is_array($paths[$resource])) {
            shuffle($paths[$resource]);
            return reset($paths[$resource]);
        }

        return $paths[$resource];
    }