Merges the indexes to the existing resources.

@param CrestApps\CodeGenerator\Models\Resource &$resource
@param (object) $input

@return int
513145
protected function mergeIndexes(&$resource, $input)
    {
        $existingNames = [];

        foreach ($resource->indexes as $index) {
            $existingNames[] = $index->getName();
        }
        $mergeIndexes = 0;
        foreach ($input->indexes as $index) {
            $newIndex = Index::fromString($index);
            if (!empty($newIndex->getName()) && in_array($newIndex->getName(), $existingNames)) {
                $this->warn('The index "' . $newIndex->getName() . '" already exists in the file.');
                continue;
            }

            $resource->indexes[] = $newIndex;
            $existingNames[] = $newIndex->getName();
            $mergeIndexes++;
        }

        return $mergeIndexes;
    }
364641
public void mergeFrom(Input input, final Object owner) throws IOException
    {
        final int first = input.readFieldNumber(this);
        if(first != ID_POJO)
            throw new ProtostuffException("order not preserved.");
        
        doMergeFrom(input, 
                strategy.resolvePojoFrom(input, ID_POJO).getSchema(), 
                owner);
    }
853866
public function add(ResourceInterface $resource): void
    {
        if (!$resource instanceof $this->interface) {
            throw new UnexpectedTypeException($resource, $this->interface);
        }

        if (in_array($resource, $this->findAll())) {
            throw new ExistingResourceException();
        }

        $this->arrayObject->append($resource);
    }
259192
public function add(ResourceInterface $resource)
    {
        $this->resources[$resource->getName()] = $resource;
        $this->indexes[] = $resource->getName();

        return $this;
    }
930706
protected function getCreateTableBlueprint(Resource $resource, MigrationInput $input)
    {
        $properties = '';

        $constraints = $this->getConstraintsFromfields($resource->fields);

        $this->addEngineName($properties, $input->engineName)
            ->addPrimaryField($properties, $this->getPrimaryField($resource->fields))
            ->addTimestamps($properties, $input->withoutTimestamps)
            ->addSoftDelete($properties, $input->withSoftDelete)
            ->addFieldProperties($properties, $resource->fields, $input->withoutTimestamps, $input->withSoftDelete)
            ->addIndexes($properties, $resource->indexes, $this->getColumnsUsedInMigration($resource, $input))
            ->addForeignConstraints($properties, $constraints);

        return $properties;
    }
423137
protected function combine($input, &$output, &$tmp)
    {
        $current = array_shift($input);

        if (\count($input) > 0) {
            foreach ($current as $element) {
                $tmp[] = $element;
                $this->combine($input, $output, $tmp);
                array_pop($tmp);
            }
        } else {
            foreach ($current as $element) {
                $tmp[] = $element;
                $output[] = $tmp;
                array_pop($tmp);
            }
        }
    }
29754
protected function getCommandInput()
    {
        $input = new ResourceInput(trim($this->argument('model-name')));
        $input->prefix = trim($this->option('routes-prefix'));
        $input->languageFileName = trim($this->option('language-filename'));
        $input->table = trim($this->option('table-name'));
        $input->viewsDirectory = trim($this->option('views-directory'));
        $input->controllerName = trim($this->option('controller-name')) ?: Helpers::makeControllerName($input->modelName);
        $input->perPage = intval($this->option('models-per-page'));
        $input->resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($input->modelName);
        $input->formRequest = $this->option('with-form-request');
        $input->controllerDirectory = $this->option('controller-directory');
        $input->controllerExtends = $this->option('controller-extends') ?: null;
        $input->withMigration = $this->option('with-migration');
        $input->force = $this->option('force');
        $input->modelDirectory = $this->option('model-directory');
        $input->primaryKey = $this->option('primary-key');
        $input->withSoftDelete = $this->option('with-soft-delete');
        $input->withoutTimeStamps = $this->option('without-timestamps');
        $input->migrationClass = $this->option('migration-class-name');
        $input->connectionName = $this->option('connection-name');
        $input->engineName = $this->option('engine-name');
        $input->template = $this->getTemplateName();
        $input->layoutName = $this->option('layout-name') ?: 'layouts.app';
        $input->tableExists = $this->option('table-exists');
        $input->translationFor = $this->option('translation-for');
        $input->withAuth = $this->option('with-auth');
        $input->formRequestDirectory = $this->option('form-request-directory');

        return $input;
    }
1191249
protected function getMigrationCapsule(MigrationInput $input, $resource, $name, $isCreate = true)
    {
        $migration = MigrationCapsule::get($name);
        $migration->path = $this->getMigrationFullName($name);
        $migration->resource = $resource;
        $migration->className = $this->makeCreateTableClassName(Helpers::makeTableName($this->tableName));
        $migration->isCreate = $isCreate;
        $migration->withoutTimestamps = $input->withoutTimestamps;
        $migration->withSoftDelete = $input->withSoftDelete;

        return $migration;
    }
1064649
public function input($input): ProcessBuilder
    {
        if ($input === null) {
            $this->input = null;

            return $this;
        }

        if (is_resource($input)) {
            $this->input = $input;

            return $this;
        }

        if (is_scalar($input)) {
            $this->input = (string) $input;
        }

        return $this;
    }
193593
public function addResource(ResourceInterface $resource) {
		if ($this->type === RelationshipObject::TO_ONE) {
			throw new InputException('can not add a resource to a to-one relationship, use ->setResource()');
		}
		
		$this->resources[] = $resource;
	}
344832
public function removeResource(Resource $resource)
    {
        if (!isset($this->resources[$resource->getUri()])) {
            return;
        }
        unset($this->resources[$resource->getUri()]);
    }
1299531
protected function hasInputIdentifier(
        ResourceTransformer $transformer,
        ResourceDefinition $resourceDefinition,
        Context $context,
        &$input
    ) {
        $identifiers = $resourceDefinition->getFields()->getIdentifiers();
        if (count($identifiers) > 0) {
            foreach ($identifiers as $field) {
                try {
                    $value = $this->resolvePropertyInput($transformer, $input, $field, $context);
                    if (!$value) {
                        return false;
                    }
                } catch (ValueUndefined $e) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }
1236151
protected function getMigrationTrackerCapsule(MigrationInput $input)
    {
        return MigrationTrackerCapsule::get($this->tableName, $input->modelName, $input->resourceFile);
    }
1139126
public function input($row, $source)
    {

        for ($i = 0; $i < count($this->container); $i++) {
            if ($this->container[$i]["source"] === $source) {
                $key = "";
                foreach ($this->container[$i]["keys"] as $cName) {
                    $key .= $row[$cName];
                }
                if (!isset($this->container[$i]['data'][$key])) {
                    $this->container[$i]['data'][$key] = array($row);
                } else {
                    array_push($this->container[$i]['data'][$key], $row);
                }
                break;
            }
        }
    }
1352105
public static function inputResource(&$resource, $bufferSize = false, $md5sum = '')
	{
		if (!is_resource($resource) || (int)$bufferSize < 0)
		{
			self::__triggerError('S3::inputResource(): Invalid resource or buffer size', __FILE__, __LINE__);
			return false;
		}

		// Try to figure out the bytesize
		if ($bufferSize === false)
		{
			if (fseek($resource, 0, SEEK_END) < 0 || ($bufferSize = ftell($resource)) === false)
			{
				self::__triggerError('S3::inputResource(): Unable to obtain resource size', __FILE__, __LINE__);
				return false;
			}
			fseek($resource, 0);
		}

		$input = array('size' => $bufferSize, 'md5sum' => $md5sum);
		$input['fp'] =& $resource;
		return $input;
	}
417002
function join($resource)
    {
        //保存到空闲连接池中
        $this->resourcePool[spl_object_hash($resource)] = $resource;
        $this->release($resource);
    }
120006
protected function createMigration($input)
    {
        if ($input->withMigration) {
            $this->call(
                'create:migration',
                [
                    'model-name' => $input->modelName,
                    '--table-name' => $input->table,
                    '--migration-class-name' => $input->migrationClass,
                    '--connection-name' => $input->connectionName,
                    '--engine-name' => $input->engineName,
                    '--resource-file' => $input->resourceFile,
                    '--template-name' => $input->template,
                    '--without-timestamps' => $input->withoutTimeStamps,
                    '--with-soft-delete' => $input->withSoftDelete,
                    '--force' => $input->force,
                ]
            );
        }

        return $this;
    }