FOF30\Form\Form::loadType PHP Method

loadType() protected method

Each type is loaded only once and then used as a prototype for other objects of same type. Please, use this method only with those entities which support types (forms don't support them).
protected loadType ( string $entity, string $type, boolean $new = true ) : mixed
$entity string The entity.
$type string The entity type.
$new boolean Flag to toggle whether we should get a new instance of the object.
return mixed Entity object on success, false otherwise.
    protected function loadType($entity, $type, $new = true)
    {
        // Reference to an array with current entity's type instances
        $types =& $this->entities[$entity];
        // Return an entity object if it already exists and we don't need a new one.
        if (isset($types[$type]) && $new === false) {
            return $types[$type];
        }
        $class = $this->loadClass($entity, $type);
        if ($class !== false) {
            // Instantiate a new type object.
            $types[$type] = new $class();
            return $types[$type];
        } else {
            return false;
        }
    }