Loops through image records and performs requested operation on them.

@param string $action
@param $model
@param array $operations
@return void
436733
protected function _loop($action, $model, $operations = [], $options = []) {
		if (!in_array($action, ['generate', 'remove', 'regenerate'])) {
			$this->_stop();
		}

		$totalImageCount = $this->_getCount($model);

		if ($totalImageCount === 0) {
			$this->out(__d('file_storage', 'No Images for model {0} found', $model));
			$this->_stop();
		}

		$this->out(__d('file_storage', '{0} image file(s) will be processed' . "\n", $totalImageCount));

		$offset = 0;
		$limit = $this->limit;

		do {
			$images = $this->_getRecords($model, $limit, $offset);
			if (!empty($images)) {
				foreach ($images as $image) {
					$Storage = StorageManager::get($image->adapter);
					if ($Storage === false) {
						$this->err(__d('file_storage', 'Cant load adapter config {0} for record {1}', $image->adapter, $image->id));
					} else {
						$payload = [
							'entity' => $image,
							'storage' => $Storage,
							'operations' => $operations,
							'versions' => array_keys($operations),
							'table' => $this->Table,
							'options' => $options
						];

						if ($action == 'generate' || $action == 'regenerate') {
							$Event = new Event('ImageVersion.createVersion', $this->Table, $payload);
							EventManager::instance()->dispatch($Event);
						}

						if ($action == 'remove') {
							$Event = new Event('ImageVersion.removeVersion', $this->Table, $payload);
							EventManager::instance()->dispatch($Event);
						}

						$this->out(__('{0} processed', $image->id));
					}
				}
			}
			$offset += $limit;
		} while ($images->count() > 0);
	}
1314079
public void validateOperations(final List<ModelNode> operations) {
        if (operations == null) {
            return;
        }

        for (ModelNode operation : operations) {
            try {
                validateOperation(operation);
            } catch (RuntimeException e) {
                if (exitOnError) {
                    throw e;
                } else {
                    System.out.println("---- Operation validation error:");
                    System.out.println(e.getMessage());
                }

            }
        }
    }
1277118
protected function runAction($action)
    {
        $dir = getcwd();
        chdir($this->getVendorDir());
        foreach ($this->managers as $m) {
            if ($m->hasDependencies()) {
                $m->runAction($action);
            }
        }
        chdir($dir);
    }
1002410
public function _execute( $action, $params = array() ) 
	{
		if ( method_exists( $this, 'action_'.$action ) ) 
		{
			call_user_func( array( $this, 'action_'.$action ), $params );
		} 
		else 
		{
			CCCli::line( "There is no action {$action}.", 'red' );
		}
	}
1306666
private function handleEditAllAction(EnvironmentInterface $environment, Action $action)
    {
        $this->clearClipboard($environment);
        $this->handleGlobalCommands($environment);
        $this->handleSessionOverrideEditAll(
            $this->getModelIds($environment, $action, $this->getSubmitAction($environment)),
            'properties',
            $environment
        );

        return  $this->callAction($environment, 'editAll', ['mode' => 'edit']);
    }
1318316
public function setAction($action) {
        $this->setVariable(self::ACTION, $this->assembleAssignmentString(self::DATA_HREF, $action));
        $this->setEventType(self::CLICK_EVENT);
        $this->addClass(self::AJAX_ELEMENT_CLASS);
        if(!$this->getId()) {
            $this->setId("button_".floor(rand(0, 1000)));
        }
    }
722069
private function process(Action $action, EnvironmentInterface $environment)
    {
        $inputProvider = $environment->getInputProvider();

        return $this->callAction(
            $environment,
            'showAll',
            \array_merge(
                $action->getArguments(),
                [
                    'mode' => $inputProvider->getParameter('mode'),
                    'select' => $inputProvider->getParameter('select')
                ]
            )
        );
    }
1067010
public function validate($operation, $model)
    {
        $model = is_array($model) ? $model : $model->getAttributes();

        $rules = $this->model->rules($operation == 'update' ? array_keys($model) : null, $operation);

        $rules = $this->interpolateValidationRules($rules, $model);

        $validator = Validator::make($model, $rules);

        $messages = [];

        if ($validator->fails()) {
            $messages = $validator->messages()->all();
        }

        // Perform other validations
        foreach ($this->validations as $validationMethod) {
            if ($message = $this->{$validationMethod}($model)) {
                $messages[] = $message;
            }
        }

        if (count($messages)) {
            throw App::make('sedp-mis.base-repository.validationException', $messages);
        }
    }
1074174
public static function runAction($db, $model, $action)
    {
        $res = $db->getConnection()->select($action['sql'], [], false);
        if ($action['action'] === 'create_table') {
            $model->onCreate();
        }
        return $res;
    }
518858
private function dispatchModelEvent($action, $collection)
    {
        if (!($this->repository instanceof DocumentRepository)) {
            return;
        }
        if (!method_exists($collection, 'getId')) {
            return;
        }

        $event = new ModelEvent();
        $event->setCollectionId($collection->getId());
        $event->setActionByDispatchName($action);
        $event->setCollectionName($this->repository->getClassMetadata()->getCollection());
        $event->setCollectionClass($this->repository->getClassName());
        $event->setCollection($collection);

        $this->eventDispatcher->dispatch($action, $event);
    }
803054
public function merge($image, int $model = 10)
    {
        $image = self::encode($image);

        return Request::exec(self::MERGE, compact('model', 'image'));
    }
206177
public function removeOperation(\CampaignChain\CoreBundle\Entity\Operation $operations)
    {
        $this->operations->removeElement($operations);
    }
149121
public function execute(StorageInterface $storage, Operations $operations)
    {
        foreach ($operations->getOperations() as $operation) {
            if ($operation instanceof AddDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_ADD_DOCUMENT, $event)
                    ->isPropagationStopped()
                ) {
                    continue;
                }

                $storage->addDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_ADD_DOCUMENT, $event);
            } elseif ($operation instanceof AddIdentityOperation) {
                throw new InvalidArgumentException('Add identity command not supported by run().');
            } elseif ($operation instanceof UpdateDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_UPDATE_DOCUMENT, $event)->isPropagationStopped()) {
                    continue;
                }

                $storage->updateDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_UPDATE_DOCUMENT, $event);
            } elseif ($operation instanceof UpdateIdentityOperation) {
                throw new InvalidArgumentException('Update identity command not supported by run().');
            } elseif ($operation instanceof DeleteDocumentOperation) {
                $storage->deleteDocument($operation->getDocument());
            } elseif ($operation instanceof DeleteIdentityOperation) {
                $storage->delete($operation->getIdentity());
            } elseif ($operation instanceof DeleteTypeOperation) {
                $storage->deleteType($operation->getType());
            } elseif ($operation instanceof DeleteAllOperation) {
                $storage->deleteAll();
            } elseif ($operation instanceof FlushOperation) {
                if ($storage instanceof Flushable) {
                    $storage->flush();
                }
            } elseif ($operation instanceof OptimizeOperation) {
                if ($storage instanceof Optimizable) {
                    $storage->optimize();
                }
            } elseif ($operation instanceof CommitOperation) {
                if ($storage instanceof Commitable) {
                    $storage->commit();
                }
            } elseif ($operation instanceof RollbackOperation) {
                if ($storage instanceof Rollbackable) {
                    $storage->rollback();
                }
            }
        }

        return true;
    }
322901
public function runAction(Action $action)
    {
        $priorAction = $this->_action;
        $this->_action = $action;
        if ($this->beforeAction($action)) {
            if (false === $action->runWithParams($this->getActionParams())) {
                $this->invalidActionParams($action);
            } else {
                $this->afterAction($action);
            }
        }
        $this->_action = $priorAction;
    }
335245
public void setActions(java.util.Collection<DatasetAction> actions) {
        if (actions == null) {
            this.actions = null;
            return;
        }

        this.actions = new java.util.ArrayList<DatasetAction>(actions);
    }
406030
private function applyOperations($operations, &$target)
    {
        foreach ($operations as $key => $operation)
        {
            $oldValue = (isset($target[$key]) ? $target[$key] : null);
            $newValue = $operation->_apply($oldValue, $this, $key);
            if (empty($newValue) && !is_array($newValue) && $newValue !== null && !is_scalar($newValue)
            )
            {
                unset($target[$key]);
                unset($this->dataAvailability[$key]);
            } else
            {
                $target[$key] = $newValue;
                $this->dataAvailability[$key] = true;
            }
        }
    }
49432
protected function processImage($action, InterventionImage $image)
    {
        $action = explode('_', $action);

        if (count($action) > 1)
        {
            list($method, $param) = $action;
        } else
        {
            $method = current($action);
            $param = [];
        }

        if ($method === 'crop')
        {
            $params = explode(',', $param);

            call_user_func_array([$image, 'crop'], $params);
        } else
        {
            call_user_func([$image, $method], $param);
        }

        return $this->saveImage($image);
    }