Generator

@return \Generator
163080
protected function loop_fields(){
        foreach( $this->fields as $name => $args ){
            $return = null;
            if( isset($args['class']) && class_exists($args['class']) ){
                $class_name = $args['class'];
                unset($args['class']);
                $args['name'] = $name;
                try{
                    $return = new $class_name($args);
                }catch ( \Exception $e ){
                    $return = new \WP_Error($e->getCode(), $e->getMessage());
                }
            }else{
                $return = new \WP_Error(500, sprintf($this->__('%s\'s argument setting is invalid.'), $name));
            }
            yield $return;
        }
    }
147566
public function yield(): Generator
	{
		foreach($this->fetchYield(PDO::FETCH_ASSOC) as $row)
		{
			yield $this->hydrateModel($row);
		}
	}
934243
public function getGeneratorStrategy()
    {
        if (!isset($this->generatorStrategy)) {
            $this->generatorStrategy = new FileWriterGeneratorStrategy(new FileLocator($this->getPath()));
        }

        return $this->generatorStrategy;
    }
31238
protected function getGeneratorConfig()
    {
        if ($this->generatorConfig === null) {
            $this->generatorConfig = new GeneratorConfig();
            $this->generatorConfig->setBuildProperties($this->getProject()->getProperties());
        }

        return $this->generatorConfig;
    }
236663
public function getIterator(): Iterator
    {
        $map = $this->map;
        foreach ($map as $ordinal => $value) {
            yield ($this->enumeration)::byOrdinal($ordinal) => $value;
        }
    }
336757
public function read(): \Generator
    {
        if ($key = $this->firstKey()) {
            yield $key => $this->get($key);
        }

        while ($key = $this->nextKey()) {
            yield $key => $this->get($key);
        }
    }
328218
private function themes(): Generator
    {
        $themes = $this->module_service->findByInterface(ModuleThemeInterface::class);

        // Last theme used
        yield $themes->get(Session::get('theme', ''));

        // Default for tree
        $tree = app(Tree::class);

        if ($tree instanceof Tree) {
            yield $themes->get($tree->getPreference('THEME_DIR'));
        }

        // Default for site
        yield $themes->get(Site::getPreference('THEME_DIR'));

        // Default for application
        yield app(WebtreesTheme::class);
    }
264761
public function getIterator(): \Generator
    {
        while (!$this->stream->eof()) {
            $item = $this->stream->read($this->chunkSize);
            // @codeCoverageIgnoreStart
            //I don't know how to fabricate this manually, so I can't test it.
            if ($item === '') {
                continue;
            }
            // @codeCoverageIgnoreEnd
            yield $item;
        }
    }
439027
public function getIterator(): \Iterator
    {
        $hydrator = $this->documentManager->newHydrator($this->hydrationMode);
        $query = clone $this->query;

        if (! $query->hasParam('_source')) {
            /** @var DocumentMetadata $class */
            $class = $this->documentManager->getClassMetadata($this->documentClass);
            $query->setSource($class->eagerFieldNames);
        }

        if (null !== $this->sort) {
            $query->setSort($this->sort);
        }

        if (null !== $this->limit) {
            $query->setSize($this->limit);
        }

        if (null !== $this->offset) {
            $query->setFrom($this->offset);
        }

        $generator = null !== $this->cacheProfile ? $this->_doExecuteCached($query) : $this->_doExecute($query);
        foreach ($generator as $resultSet) {
            yield from $hydrator->hydrateAll($resultSet, $this->documentClass);
        }
    }
996949
public function convertGenerator() : \Generator {

		yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );

		// Sanity check

		if ( empty( $this->tmpDir ) || ! is_dir( $this->tmpDir ) ) {
			$this->logError( '$this->tmpDir must be set before calling convert().' );
			throw new \Exception();
		}

		if ( empty( $this->exportStylePath ) || ! is_file( $this->exportStylePath ) ) {
			$this->logError( '$this->exportStylePath must be set before calling convert().' );
			throw new \Exception();
		}

		// Convert
		yield 2 => $this->generatorPrefix . __( 'Preparing book contents', 'pressbooks' );
		$metadata = Book::getBookInformation();
		$book_contents = $this->preProcessBookContents( Book::getBookContents() );

		// Set two letter language code
		if ( isset( $metadata['pb_language'] ) ) {
			list( $this->lang ) = explode( '-', $metadata['pb_language'] );
		}

		try {

			yield 5 => $this->generatorPrefix . __( 'Creating container', 'pressbooks' );
			$this->createContainer();
			yield from $this->createOEBPSGenerator( $book_contents, $metadata );
			$this->createOPF( $book_contents, $metadata );
			$this->createNCX( $book_contents, $metadata );

		} catch ( \Exception $e ) {
			$this->logError( $e->getMessage() );
			throw new \Exception();
		}

		yield 75 => $this->generatorPrefix . __( 'Saving file to exports folder', 'pressbooks' );
		$filename = $this->timestampedFileName( $this->suffix );
		if ( ! $this->zipEpub( $filename ) ) {
			throw new \Exception();
		}
		$this->outputPath = $filename;
		yield 80 => $this->generatorPrefix . __( 'Export successful', 'pressbooks' );
	}
969097
private function middlewareGenerator()
    {
        $middlewares = $this->middleware;
        ksort($middlewares);

        foreach ($middlewares as $priorityGroup) {
            foreach ($priorityGroup as $middleware) {
                yield $middleware;
            }
        }
    }
937707
public function generate()
    {
        $saved = $this->factoryMuffin->isPendingOrSaved($this->model);

        return call_user_func($this->kind, $this->model, $saved);
    }
759037
public function getIterator()
    {
        $this->reset();

        foreach ($this->iterator as $key => $value) {
            $this->position++;
            yield $key => $value;
        }
    }
1167791
public function generateResources()
    {
        app('Luthfi\CrudGenerator\Generators\LangFileGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\FormViewGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\IndexViewGenerator', ['command' => $this])->generate();
        app('Luthfi\CrudGenerator\Generators\ShowViewGenerator', ['command' => $this])->generate();
    }
190508
protected function createGenerator()
    {
        $filesystem = $this->getContainer()->get('filesystem');
        $registry = $this->getContainer()->get('doctrine');

        return new DefaultSiteGenerator($filesystem, $registry, '/defaultsite', $this->assistant, $this->getContainer());
    }
1257869
public function getChildNodes() : \Generator {
        foreach ($this::CHILD_NAMES as $name) {
            $val = $this->$name;
            if (\is_array($val)) {
                foreach ($val as $child) {
                    if ($child instanceof Node) {
                        yield $child;
                    }
                }
                continue;
            } elseif ($val instanceof Node) {
                yield $val;
            }
        }
    }
690247
public function run()
	{
		$this->generator->addRaw(
			array(
				  'location'         => 'example.com',
				  'last_modified'    => '2013-01-28',
				  'change_frequency' => 'weekly',
				  'priority'         => '0.65'
			)
		);

		$this->generator->addRaw(
			array(
				  'location'         => 'example.com/test',
				  'last_modified'    => '2013-12-28',
				  'change_frequency' => 'weekly',
				  'priority'         => '0.95'
			)
		);

		$this->generator->addRaw(
			array(
				  'location'         => 'example.com/test/2',
				  'last_modified'    => '2013-12-25',
				  'change_frequency' => 'weekly',
				  'priority'         => '0.99'
			)
		);

		return $this->generator->generate();
	}