Add an instance of the selected class
@throws common_exception_BadRequest
@return void
337799
public function addInstanceForm()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }

        $clazz = $this->getCurrentClass();
        $formContainer = new tao_actions_form_CreateInstance(array($clazz), array());
        $myForm = $formContainer->getForm();

        if ($myForm->isSubmited() && $myForm->isValid()) {
            $properties = $myForm->getValues();
            $instance = $this->createInstance(array($clazz), $properties);

            $this->setData('message', __('%s created', $instance->getLabel()));
            $this->setData('reload', true);
        }

        $this->setData('formTitle', __('Create instance of ').$clazz->getLabel());
        $this->setData('myForm', $myForm->render());

        $this->setView('form.tpl', 'tao');
    }
769816
public function addClass() {
    $args = func_get_args();
    if ($args) {
      $classes = array();
      foreach ($args as $arg) {
        // Merge the values passed in from the classes array.
        // The argument is cast to an array to support comma separated single
        // values or one or more array arguments.
        $classes = array_merge($classes, (array) $arg);
      }

      // Merge if there are values, just add them otherwise.
      if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) {
        // Merge the values passed in from the class value array.
        $classes = array_merge($this->storage['class']->value(), $classes);
        $this->storage['class']->exchangeArray($classes);
      }
      else {
        $this->offsetSet('class', $classes);
      }
    }

    return $this;
  }
53647
private function load()
    {
        if ($this->isVirgin()) {
            throw new \BadMethodCallException(
                get_class($this) . '#' . $this->getUid()
                . ': Please call setData() directly after instantiation first.',
                1331489395
            );
        }

        if ($this->isGhost()) {
            if (!$this->hasLoadCallBack()) {
                throw new \BadMethodCallException(
                    'Ghosts need a load callback function before their data can be accessed.',
                    1331489414
                );
            }

            $this->markAsLoading();
            call_user_func($this->loadCallback, $this);
        }
    }
617744
public function add() {
		$this->out('CakePHP Queue RetryExample task.');
		$this->hr();
		$this->out('This is a very simple example of a QueueTask and how retries work.');
		$this->out('I will now add an example Job into the Queue.');
		$this->out('This job will only produce some console output on the worker that it runs on.');
		$this->out(' ');
		$this->out('To run a Worker use:');
		$this->out('	bin/cake queue runworker');
		$this->out(' ');
		$this->out('You can find the sourcecode of this task in: ');
		$this->out(__FILE__);
		$this->out(' ');

		if (file_exists($this->file)) {
			$this->warn('File seems to already exist. Make sure you run this task standalone. You cannot run it multiple times in parallel!');
		}

		file_put_contents($this->file, '0');

		/*
		 * Adding a task of type 'example' with no additionally passed data
		 */
		$this->QueuedJobs->createJob('RetryExample');
		$this->success('OK, job created, now run the worker');
	}
1244747
public void addException(ClassConstant type, int start, int end, int handler)
  {
    _exceptions.add(new ExceptionItem(type.getIndex(), start, end, handler));
  }
758124
private function _setRequest()
	{
		if ($this->_requestUri !== NULL) {
            $this->_request = preg_replace('#(^/)|(^' . ROOT . ')|(/$)#', '', $this->_requestUri);

            if (! $this->_request) {
            	$this->_request = self::DEFAULT_MODULE . '/' . self::DEFAULT_VIEW;
            }

            $this->_requestVars = explode('/', $this->_request);
            if (count($this->_requestVars) == 1) {
				$this->_request       .= '/' . self::DEFAULT_VIEW;
				$this->_requestVars[]  = self::DEFAULT_VIEW;
            }

            return $this;
        }

        throw new Exception('Request URI is not available');
	}
1057693
public function init()
	{
		if (!isset($this->form))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Form is not set.');

		if (!isset($this->model))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Model is not set.');

		if (!isset($this->type))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Input type is not set.');

		if ($this->type === self::TYPE_UNEDITABLE)
		{
			if (isset($this->htmlOptions['class']))
				$this->htmlOptions['class'] .= ' uneditable-input';
			else
				$this->htmlOptions['class'] = 'uneditable-input';
		}

		$this->processHtmlOptions();
	}
1084805
public function checkLogin()
    {
        $this->defaultData();
        $userService = $this->getServiceLocator()->get(tao_models_classes_UserService::class);
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        }

        $data = array('available' => false);
        if ($this->hasRequestParameter('login')) {
            $data['available'] = $userService->loginAvailable($this->getRequestParameter('login'));
        }

        $this->returnJson($data);
    }
177817
public function add()
    {
        $group = $this->Groups->newEntity();
        if ($this->request->is('post') && !empty($this->request->data)) {
            $this->Groups->patchEntity($group, $this->request->data);
            if ($this->Groups->save($group)) {
                $this->Flash->success(__d('wasabi_core', 'The group <strong>{0}</strong> has been created.', $this->request->data['name']));
                $this->redirect(['action' => 'index']);
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }
        $this->set('group', $group);
    }
1069123
public function add()
	{
		// Get the hook we're setting
		$trigger = $this->arguments->getOpt(3);
		$hook    = $this->arguments->getOpt(4);

		// Delete the primary args so they aren't added as top level config values
		$this->arguments->deleteOpt(3);
		$this->arguments->deleteOpt(4);

		// Set the new hooks argument
		$this->arguments->setOpt('hooks', array($trigger => array($hook)));

		// Redirect back to the basic configuration set method
		App::get('client')->call('configuration', 'set', $this->arguments, $this->output);
	}
696757
public function add()
    {
        $table = $this->loadModel();

        $entity = $table->newEntity();

        if ($this->request->is('post')) {
            $post_data = $this->request->getParam(
                'data',
                (array)$this->request->getData()
            );

            $response = $this->persistEntity($entity, $post_data);
            if ($response) {
                $this->saveAssociations($entity, $post_data);

                return $response;
            }
        }

        $this->set('entity', $entity);
        $this->render('CsvMigrations.Common/add');
        $this->set('_serialize', ['entity']);
    }
1029504
public function add()
    {
        $group = $this->Groups->newEntity();
        if ($this->request->is('post')) {
            $group  = $this->Groups->patchEntity($group, $this->request->getData());
            $result = $this->Groups->save($group);
            if ($result) {
                $this->Flash->success(__d('community', 'The group has been saved.'));
                return $this->App->redirect([
                    'apply' => ['action' => 'edit', $result->id],
                ]);
            } else {
                $this->Flash->error(__d('community', 'The group could not be saved. Please, try again.'));
            }
        }

        $parents = $this->Groups->getTreeList();
        $this->set(compact('group', 'parents'));
        $this->set('page_title', __d('community', 'Add new group'));
    }
639172
public function import()
    {
        switch ($this->serviceGroupType) {
            case ServiceTypeGroups::DATABASE:
                $header = $this->getHeader();
                if ($this->createDbTableFromHeader($header)) {
                    try {
                        $this->importData();

                        return true;
                    } catch (\Exception $e) {
                        $this->revert();

                        throw $e;
                    }
                }
                break;
            default:
                throw new BadRequestException(
                    'Importing resource(s) to service type group [' . $this->serviceGroupType . '] ' .
                    'is not currently supported.'
                );
        }
    }
317696
public function add()
    {
        $this->loadModel('User.Users');
        $user = $this->Users->newEntity();
        $user = $this->Users->attachFields($user);
        $languages = LocaleToolbox::languagesList();
        $roles = $this->Users->Roles->find('list', [
            'conditions' => [
                'id NOT IN' => [ROLE_ID_AUTHENTICATED, ROLE_ID_ANONYMOUS]
            ]
        ]);

        if ($this->request->data()) {
            $user->accessible('id', false);
            $data = $this->request->data;

            if (isset($data['welcome_message'])) {
                $sendWelcomeMessage = (bool)$data['welcome_message'];
                unset($data['welcome_message']);
            } else {
                $sendWelcomeMessage = false;
            }

            $user = $this->Users->patchEntity($user, $data);
            if ($this->Users->save($user)) {
                if ($sendWelcomeMessage) {
                    NotificationManager::welcome($user)->send();
                }

                $this->Flash->success(__d('user', 'User successfully registered!'));
                $this->redirect(['plugin' => 'User', 'controller' => 'manage', 'action' => 'edit', $user->id]);
            } else {
                $this->Flash->danger(__d('user', 'User could not be registered, please check your information.'));
            }
        }

        $this->title(__d('user', 'Register New User'));
        $this->set(compact('user', 'roles', 'languages'));
        $this->Breadcrumb->push('/admin/user/manage');
    }
833815
public function add()
    {
        $this->view = 'scaffold/add';
        $form = new Form(
            "add-{$this->get('modelSingular')}", $this->getDescriptor()
        );
        if ($this->request->isPost()) {
            $form->setData($this->request->getPost());
            if ($form->isValid()) {
                try {
                    $modelClass = $this->getModelName();
                    /** @var Model $model */
                    $model = new $modelClass($form->getValues());
                    $model->save();
                    $name = ucfirst($this->get('modelSingular'));
                    $this->addSuccessMessage(
                        "{$name} successfully created."
                    );
                    $pmk = $model->getPrimaryKey();
                    $this->redirect(
                        $this->_basePath .'/'.
                        $this->get('modelPlural').'/show/'.$model->$pmk
                    );
                    return;
                } catch (Database\Exception $exp) {
                    $this->addErrorMessage(
                        "Error while saving {$this->get('modelSingular')}} " .
                        "data: {$exp->getMessage()}"
                    );
                }
            } else {
                $this->addErrorMessage(
                    "Cannot save {$this->get('modelSingular')}. " .
                    "Please correct the errors bellow."
                );
            }
        }
        $descriptor =  $this->getDescriptor();
        $this->set(compact('form', 'descriptor'));
    }
277481
public function addInstanceDocument( $instance_file = null, $taxonomy_file = null )
	{
		$this->log()->info( "$instance_file" );

		if ( $this->hierarchies !== null )
			throw new Exception( "An instance document cannot be added to a report once the report has been prepared" );

		if ( $instance_file === null )
			throw new Exception( "An instance document has not been supplied." );

		if ( isset( $this->instanceDocuments[ $instance_file ] ) )
			throw new Exception( "The instance document has already been loaded" );

		// Load the document
		/**
		 * An instance document instance
		 * @var XBRL_Instance $instance
		 */
		$instance = null;
		if ( ! XBRL_Instance::FromInstanceDocument( $instance_file, $taxonomy_file, $instance ) )
		{
			throw new Exception( $instance->getError() );
		}

		// If no schema file is yet set, record it.  If the name of the taxonomy schema
		// associated with the instance document loaded is different to the schema of
		// a previously loaded instance document then report an error.
		$schemaFilename = $instance->getSchemaFilename();
		if ( $this->schemaFilename === null )
			$this->schemaFilename = $schemaFilename;
		else if ( $this->schemaFilename !== $schemaFilename )
			throw new Exception( "Instance documents being compared must use the the same taxonomy schema." );

		// Record it
		$this->instanceDocuments[ $instance_file ] =& $instance;
		$this->analyzeContexts( $instance );

		// If no taxonomy is set then record it as well.  Only one taxonomy is allowed per report.
		if ( ! isset( $this->taxonomy ) || $this->taxonomy === null )
			$this->taxonomy =& $instance->getInstanceTaxonomy();
	}
663758
public function add()
    {
        $this->loadModel('Content.ContentTypes');
        $this->loadModel('User.Roles');
        $type = $this->ContentTypes->newEntity();

        if ($this->request->data()) {
            $type = $this->ContentTypes->patchEntity($type, $this->request->data());
            $errors = $type->errors();
            $success = empty($errors);

            if ($success) {
                $success = $this->ContentTypes->save($type);
                if ($success) {
                    $this->Flash->success(__d('content', 'Content type created, now attach some fields.'));
                    $this->redirect(['plugin' => 'Content', 'controller' => 'fields', 'type' => $type->slug]);
                }
            }

            if (!$success) {
                $this->Flash->danger(__d('content', 'Content type could not be created, check your information.'));
            }
        }

        $roles = $this->Roles->find('list');
        $this->title(__d('content', 'Define New Content Type'));
        $this->set(compact('type', 'roles'));
        $this->set('languages', LocaleToolbox::languagesList());
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Content Types'), '/admin/content/types')
            ->push(__d('content', 'Creating Content Type'), '#');
    }