Returns an object blueprint
@param string $name factory name
@param string $type variation or fixture name
@param array $override overriden attributes values
@param boolean $persisted wether it will save the object or not
@return \Phactory\Blueprint
187469
public static function getBlueprint($name, $type, $override = array(), $persisted = true)
    {
        $factory = self::loader()->load($name);

        return $factory->create($type, $override, $persisted);
    }
1147420
public function createAction($name, $type = null, array $options = [])
    {
        $this->preventIfLocked();

        if (null !== $type) {
            return $this->getFactory()->createActionBuilder($name, $type, $options);
        }

        throw new \InvalidArgumentException('Action type guessing is not yet supported.');
        // TODO return $this->getFormFactory()->createActionBuilderForProperty($this->getDataClass(), $name, $options);
    }
1012016
public function searchByNameAndType($name = null, $type = null)
    {
        $searchResult = $this->getRequest()->request(
            'POST',
            $this->getRequestUrl('models/searches'),
            [
                'model_query' => [
                    'name' => $name,
                    'type' => $type,
                ],

            ]
        );

        return $this->getModelsFromResult($searchResult);
    }
96895
protected static function mapToDatabase($type, $valueName) {
    $mapper = self::getMapper($type);
    if ($mapper->hasAttribute($valueName)) {
      $attributeDescription = $mapper->getAttribute($valueName);
    }
    else {
      // if the attribute does not exist, it might be the column name already
      foreach ($mapper->getAttributes() as $curAttributeDesc) {
        if ($curAttributeDesc->getColumn() == $valueName) {
          $attributeDescription = $curAttributeDesc;
          break;
        }
      }
    }
    if (!$attributeDescription) {
      throw new PersistenceException("No attribute '".$valueName."' exists in '".$type."'");
    }

    $table = $mapper->getRealTableName();
    $column = $attributeDescription->getColumn();
    return [$table, $column];
  }
1015183
public static function create($name, $type = NULL, $defaultValue = self::UNDEFINED, $modifiers = self::MODIFIER_PROTECTED) {
    if (isset($type)) {
      if ($type instanceof GClass) {
        $type = new ObjectType(new GClass($type->getFQN()));
      } elseif (!($type instanceof Type)) {
        $type = Type::create($type);
      }
    }
    
    return new static($name, $type, $defaultValue, $modifiers);
  }
191657
public function createForm($name, $type = "form", array $data = array(), array $options = array())
    {
        if (empty($name)) {
            $name = static::EMPTY_FORM_NAME;
        }

        return $this->getTheliaFormFactory()->createForm($name, $type, $data, $options);
    }
1201025
public static function create($name, $type, $extension, $vendor)
    {
        // Prepare the component name
        $componentLabel = $componentName = array_pop($name);
        if (substr($componentName, -9) !== 'Component') {
            $componentName .= 'Component';
        }

        // Prepare the component directory
        $componentPath    = implode(DIRECTORY_SEPARATOR, $name);
        $componentAbsPath = GeneralUtility::getFileAbsFileName(
            'EXT:'.$extension.DIRECTORY_SEPARATOR.'Components'.DIRECTORY_SEPARATOR
            .implode(DIRECTORY_SEPARATOR, $name)
        );
        if (!is_dir($componentAbsPath) && !mkdir($componentAbsPath, 06775, true)) {
            throw new CommandException('Could not create component directory', 1507997978);
        }

        // Prepare the component namespace
        $componentNamespace = rtrim(
            $vendor.'\\'.GeneralUtility::underscoredToUpperCamelCase($extension)
            .'\\Component\\'.implode('\\', $name),
            '\\'
        );

        // Copy the skeleton template
        $substitute       = [
            '###extension###' => $extension,
            '###namespace###' => $componentNamespace,
            '###label###'     => $componentLabel,
            '###tspath###'    => strtolower(implode('.', array_merge($name, [$componentLabel]))),
            '###path###'      => $componentPath,
        ];
        $skeletonTemplate = GeneralUtility::getFileAbsFileName(
            'EXT:tw_componentlibrary/Resources/Private/Skeleton/'.ucfirst($type).'.php'
        );
        $skeletonString   = strtr(file_get_contents($skeletonTemplate), $substitute);
        $skeletonFile     = $componentAbsPath.DIRECTORY_SEPARATOR.$componentName.'.php';
        file_put_contents($skeletonFile, $skeletonString);
        chmod($skeletonFile, 0664);
    }
1356564
public function create($overrides = array(), $associated = array()) {
        $data = $this->build($overrides, $associated);
        $this->_collection->insert($data,array("w"=>1));
        return $data;
    }
1059045
public function object_get( $type, $name ) {

		$object = self::$post_types;

		if ( 'term' == $type ) {
			$type = 'taxonomy';
		}

		if ( 'taxonomy' == $type ) {
			$object = self::$taxonomies;
		} elseif ( 'media' == $type ) {
			$object = self::$media;
		} elseif ( 'user' == $type ) {
			$object = self::$user;
		} elseif ( 'comment' == $type ) {
			$object = self::$comment;
		}

		if ( 'pod' != $type && ! empty( $object ) && is_array( $object ) && isset( $object[ $name ] ) ) {
			$pod = $object[ $name ];
		} else {
			if ( empty( self::$current_pod_data ) || ! is_object( self::$current_pod_data ) || self::$current_pod_data['name'] != $name ) {
				self::$current_pod_data = pods_api()->load_pod( array( 'name' => $name ), false );
			}

			$pod = self::$current_pod_data;
		}

		if ( empty( $pod ) ) {
			return array();
		}

		$defaults = array(
			'name'   => 'post',
			'object' => 'post',
			'type'   => 'post_type'
		);

		$pod = array_merge( $defaults, (array) $pod );

		if ( empty( $pod['name'] ) ) {
			$pod['name'] = $pod['object'];
		} elseif ( empty( $pod['object'] ) ) {
			$pod['object'] = $pod['name'];
		}

		if ( $pod['type'] != $type ) {
			return array();
		}

		return $pod;
	}
1184557
protected function createBlueprint($type, Closure $callback = null, $index = null)
    {
        if (isset($this->resolver)) {
            return call_user_func($this->resolver, $type, $callback, $index);
        }

        return new Blueprint($type, $callback, $index);
    }
35068
public static function getOrCreateRepository($name)
    {
        $name = $name == Repository::class
            ? 'default'
            : str_replace(Repository::class . '.', '', $name);

        $repository = null;
        if (array_key_exists($name, static::$repositories)) {
            $repository = static::$repositories[$name];
        } else {
            $fullName = Repository::class . '.' . $name;
            if (!context()->exists($fullName)) {
                /**
                 * Lazy load.
                 */
                $config = config('database.' . $name);
                /**
                 * @T00D00 - this means that we're overloading every non-default repository to default one?
                 *         - this is needed when mixing different and using multiple repositories
                 *         - maybe the best thing would be to change repositories when needed (leave defaults?)
                 */
                if (!$config && $name != 'default') {
                    $config = config('database.default');
                }
                $repository = RepositoryFactory::getRepositoryByConfig($config, $name);
                context()->bind($fullName, $repository);
            }

            $repository = context()->get($fullName);
        }

        if (!$repository) {
            throw new Exception('Cannot prepare repository');
        }

        return $repository;
    }
597186
private function generateGetter(string $name, string $type): EntityGenerator
    {
        if ('datetime' === $type) {
            $type = '\DateTime';
        }

        $this->entityClass
            ->addMethod('get' . ucfirst($name))
            ->setVisibility('public')
            ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ' . $name . PHP_EOL)
            ->addComment('@return ' . $type)
            ->setReturnType($type)
            ->addBody('return $this->' . $name . ';');

        return $this;
    }
895782
protected static function getMapper($type, $strict=true) {
    $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
    $mapper = $persistenceFacade->getMapper($type);
    if ($strict && !($mapper instanceof RDBMapper)) {
      throw new PersistenceException('Only PersistenceMappers of type RDBMapper are supported.');
    }
    return $mapper;
  }
157147
protected static function getRepositoryByConfig($config, $name)
    {
        if (!is_array($config)) {
            if (class_exists($config)) {
                return new $config;
            }

            throw new Exception('Cannot create repository from string');
        } elseif ($config['driver'] == 'faker') {
            return new Faker(Factory::create());
        } elseif ($config['driver'] == 'middleware') {
            return resolve($config['middleware'])->execute(function() {
            }
            );
        }

        return static::initPdoDatabase($config, $name);
    }
763022
public function findReversed($name, $reload = false, $type = 'all')
	{
		return $this->find($name, $reload, true, $type);
	}
458563
private function getExtension($type, $name)
    {
        if (!$this->extensions[$type]) {
            $this->discoverExtension($type);
        }

        if (array_key_exists($name, $this->extensions[$type])) {
            return $this->extensions[$type][$name];
        }

        return null;
    }
33424
public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('publishedRevision.revisionId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.publishedRevision', 'publishedRevision')
            ->join('page.site', 'site')
            ->where('site.siteId = :siteId')
            ->andWhere('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->setParameter('siteId', $siteId)
            ->setParameter('pageName', $name)
            ->setParameter('pageType', $type);

        try {
            return $queryBuilder->getQuery()->getSingleScalarResult();
        } catch (NoResultException $e) {
            return null;
        }
    }