Create new virtual stream entity.

@return $this
497916
public static function newInstance(EntityInterface $entity, string $path, string $name = null): self
    {
        if (null === $name) {
            $name = $entity->basename();
        }
        $instance = new static($name, $path);
        $instance->realEntity = $entity;

        return $instance;
    }
93697
public function stream()
    {
        $stream = fopen($this->file, 'r');

        $stream = $stream === false ? null : $stream;

        return new Stream($stream);
    }
29776
public function create()
    {
        $instance = self::createRefundTransaction($this);
        $this->setId($instance->getId());
        return $instance;
    }
1222894
public function create()
    {
        $instance = self::createWishList($this);
        $this->setId($instance->getId());
        return $instance;
    }
1323180
public function connection()
    {
        if (!is_object($this->db)) {
            $this->db = new DB;
            $this->db->addConnection($this->database);
            $this->db->setEventDispatcher(new Dispatcher(new Container));
            $this->db->setAsGlobal();
            $this->db->bootEloquent();
        }

        return $this;
    }
749880
private function entityFactory()
    {
        // this is a little tortuous but some constructor flows require the EntityManager
        // as this point in the refactor I'm unwilling to modify the constructor of the Entity
        // TODO. Fix this. Constructor injection
        $entity = $this->reflEntityClass->newInstanceWithoutConstructor();
        // add the entityManager
        if( $this->reflEntityManagerPropertyOfEntity ) {
            $this->reflEntityManagerPropertyOfEntity->setValue($entity, $this->entityManager);
        }
        // call the original constructor
        call_user_func_array( [$entity, '__construct'], func_get_args() );
        return $entity;
    }
112717
public function create()
	{
		// Set some options
		switch ($this->source)
		{
			case 'image':
				$extensions = \Config::get('validImageTypes');
				$orderField = $this->virtualFieldName('orderSRC');
				$isGallery = true;
				$isDownloads = false;
				break;
				
			case 'video':
				$extensions = \Config::get('validVideoTypes');
				$orderField = false;
				$isGallery = false;
				$isDownloads = true;
				break;
				
			case 'audio':
				$extensions = \Config::get('validAudioTypes');
				$orderField = false;
				$isGallery = false;
				$isDownloads = true;
				break;
				
			case 'custom':
				$extensions = $this->customExtension;
				$orderField = $this->virtualFieldName('orderSRC');
				$isGallery = false;
				$isDownloads = ($this->canSelectFolder) ? true : false;
				break;
				
			default:
				$extensions = \Config::get('allowedDownload');
				$orderField = $this->virtualFieldName('orderSRC');
				$isGallery = false;
				$isDownloads = true;
				break;				
		}

		if ($this->multiSource)
		{

			// The multiSRC field
			$this->generateDCA('multiSRC', array
			(
				'inputType' =>	'fileTree',
				'label'		=>	array($this->label, $this->description),
				'eval'     	=> 	array
				(
					'multiple'		=>	true,				
					'fieldType'		=>	'checkbox', 
					'orderField'	=>	$orderField,
					'files'			=>	true,
					'filesOnly'		=>	!$this->canSelectFolder,
					'extensions' 	=>	$extensions,
					'isGallery'		=>	$isGallery,
					'isDownloads'	=>	$isDownloads,
					'mandatory'		=>	($this->mandatory) ? true : false, 
					'tl_class'		=>	'clr',
				),
				'load_callback'		=> (!$orderField) ?: array
				(
					array('tl_content_elements', 'prepareOrderValue'),
				),
				'save_callback'		=> (!$orderField) ?: array
				(
					array('tl_content_elements', 'saveOrderValue'),
				),
			));

			// The orderSRC field
			if ($orderField)
			{
				$this->generateDCA('orderSRC', array(), false, false);
			}
		}
		else
		{
			// the singleSRC field
			$this->generateDCA('singleSRC', array
			(
				'inputType' =>	'fileTree',
				'label'		=>	array($this->label, $this->description),
				'eval'     	=> 	array
				(
					'fieldType'		=>	'radio', 
					'files'			=>	true, 
					'extensions' 	=>	$extensions,
					'mandatory'		=>	($this->mandatory) ? true : false, 
					'tl_class'		=>	'clr',
				),
			));
			
		}
		
		// The size field
		if ($this->source == 'image' && $this->canChangeSize)
		{
			$this->generateDCA('size', array
			(
				'inputType'			=> 'imageSize',
				'label'				=> &$GLOBALS['TL_LANG']['tl_content']['size'],
				'options'			=> $this->getImageSizeList(),
				'default'			=> $this->size,
				'reference'			=> &$GLOBALS['TL_LANG']['MSC'],
				'eval' =>	array
				(
					'rgxp' =>' natural', 
					'includeBlankOption' => false, 
					'nospace' => true, 
					'tl_class' => 'w50',
				),
				'load_callback'	=>	array
				(
					array('tl_content_elements','defaultValue')
				),
			));	
		}

		// The sortBy field
		if ($this->multiSource && $this->canChangeSortBy)
		{
			$this->generateDCA('sortBy', array
			(
				'inputType'               => 'select',
				'label'                   => &$GLOBALS['TL_LANG']['tl_content']['sortBy'],
				'options'                 => array('custom', 'name_asc', 'name_desc', 'date_asc', 'date_desc', 'random'),
				'reference'               => &$GLOBALS['TL_LANG']['tl_content'],
				'eval'                    => array
				(
					'tl_class'=>'w50'
				),
			));		
		}
	}
998748
public function newAction()
    {
        $entity = new Family();
        $form   = $this->createForm(new FamilyType(), $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
1236212
public function create(): self
    {
        $this->logger->info('create new queue ['.$this->name.']', [
            'category' => get_class($this),
        ]);

        try {
            $this->db->createCollection(
                $this->name,
                [
                    'capped' => true,
                    'size' => $this->size,
                ]
            );

            $this->db->{$this->name}->insertOne(['class' => 'dummy']);
        } catch (RuntimeException $e) {
            //ignore if code 48 (collection does already exist)
            if (48 !== $e->getCode()) {
                throw $e;
            }
        }

        return $this;
    }
651761
public function create()
    {
        if (! $this->adapter->fileExists($this->path, true)) {
            // ensure the parent directory exists
            new Directory(dirname($this->path), $this->adapter);

            if ($this->adapter->createFile($this->path) === false) {
                $this->throwUnableToCreate();
            }
        }

        return $this;
    }
1078663
public function create()
    {
        $instance = self::createOrderLineItem($this);
        $this->setId($instance->getId());
        return $instance;
    }
419140
public function newAction()
    {
        $entity = new Collection();
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
623663
public function setStream(string $stream): self
    {
        $this->stream = $stream;
        $this->createByteCache();
        return $this;
    }
988411
public function create()
    {
        $this->resource = imagecreatetruecolor($this->width, $this->height);
        imagesavealpha($this->resource, true);

        $color = imagecolorallocatealpha(
            $this->resource,
            $this->red,
            $this->green,
            $this->blue,
            null
        );

        if ($this->figureType == 'rectangle') {
            $this->createRectangle($color);
        }

        if ($this->figureType == 'ellipse') {
            $this->createEllipse($color);
        }

        $this->addOpacityFilter();

        return $this;
    }
1125647
protected function createEach() {
        foreach ($this->providers as $class => &$data) {
            if ( ! array_get($data, 'instance')) {
                $instance = $this->getProviderInvoker()
                    ->create($class, $this->getSharedArguments());
                array_set($data, 'instance', $instance);

                $this->create();
                break;
            }
        }
    }
504017
public function create()
    {
        /**
         * @var Attribute $attribute
         */
        $classNamespace = $this->getEntityNamespace();
        $attribute = new $classNamespace();
        $attribute->setEnabled(true)
            ->setValues(new ArrayCollection())
            ->setCreatedAt($this->now());

        return $attribute;
    }
386603
public function createAction()
    {
        // Load form
        $entityClass = $this->getModuleNamespace() . '\Entity\\' . $this->getEntityName();
        $entity      = new $entityClass();
        $form        = $this->getForm('Create' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Create account
            $result = $this->getService()->create();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/create');

        return $viewModel;
    }