Creates a new MeasureUnit entity.

@Route("/create", name="admin_shop_measure_unit_create")
@Method("POST")
@Template("FlowerStockBundle:MeasureUnit:new.html.twig")
490557
public function createAction(Request $request)
    {
        $measureunit = new MeasureUnit();
        $form = $this->createForm(new MeasureUnitType(), $measureunit);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($measureunit);
            $em->flush();

            return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
        }

        return array(
            'measureunit' => $measureunit,
            'form' => $form->createView(),
        );
    }
1094867
public function create()
    {
        if (!userHasPermission('admin:blog:post:' . $this->blog->id . ':create')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Set method info
        $this->data['page']->title = 'Create New ' . ucfirst($this->data['postName']);

        // --------------------------------------------------------------------------

        //  Process POST
        if ($this->input->post()) {

            //  Are we running in preview mode?
            $bIsPreview = (bool) $this->input->post('isPreview');

            //  Only validate non-previews
            if (empty($bIsPreview)) {

                $oFormValidation = Factory::service('FormValidation');

                $oFormValidation->set_rules('is_published', '', '');
                $oFormValidation->set_rules('published', '', '');
                $oFormValidation->set_rules('title', '', 'required');
                $oFormValidation->set_rules('type', '', 'required');
                $oFormValidation->set_rules('body', '', 'required');
                $oFormValidation->set_rules('excerpt', '', '');
                $oFormValidation->set_rules('image_id', '', '');
                $oFormValidation->set_rules('video_url', '', '');
                $oFormValidation->set_rules('audio_url', '', '');
                $oFormValidation->set_rules('seo_description', '', '');
                $oFormValidation->set_rules('seo_keywords', '', '');

                if ($this->input->post('slug')) {

                    $sTable = $this->blog_post_model->getTableName();
                    $oFormValidation->set_rules(
                        'slug',
                        '',
                        'trim|alpha_dash|is_unique[' . $sTable . '.slug]'
                    );
                }

                if ($this->input->post('type') === 'PHOTO') {

                    $oFormValidation->set_rules('image_id', '', 'required');

                } elseif ($this->input->post('type') === 'VIDEO') {

                    $oFormValidation->set_rules('video_url', '', 'required');

                } elseif ($this->input->post('type') === 'AUDIO') {

                    $oFormValidation->set_rules('audio_url', '', 'required');
                }

                $oFormValidation->set_message('required', lang('fv_required'));
                $oFormValidation->set_message('alpha_dash', lang('fv_alpha_dash'));
                $oFormValidation->set_message('is_unique', 'A post using this slug already exists.');

            }

            if (!empty($bIsPreview) || $oFormValidation->run($this)) {

                //  Prepare data
                $aData                     = array();
                $aData['blog_id']          = $this->blog->id;
                $aData['title']            = $this->input->post('title');
                $aData['type']             = $this->input->post('type');
                $aData['slug']             = $this->input->post('slug');
                $aData['excerpt']          = $this->input->post('excerpt');
                $aData['image_id']         = (int) $this->input->post('image_id');
                $aData['image_id']         = $aData['image_id'] ? $aData['image_id'] : null;
                $aData['video_url']        = trim($this->input->post('video_url'));
                $aData['video_url']        = $aData['video_url'] ? $aData['video_url'] : null;
                $aData['audio_url']        = trim($this->input->post('audio_url'));
                $aData['audio_url']        = $aData['audio_url'] ? $aData['audio_url'] : null;
                $aData['body']             = $this->input->post('body');
                $aData['seo_description']  = $this->input->post('seo_description');
                $aData['seo_keywords']     = $this->input->post('seo_keywords');
                $aData['is_published']     = (bool) $this->input->post('is_published');
                $aData['published']        = $this->input->post('published');
                $aData['associations']     = $this->input->post('associations');
                $aData['gallery']          = $this->input->post('gallery');
                $aData['comments_enabled'] = $this->input->post('comments_enabled');
                $aData['comments_expire']  = $this->input->post('comments_expire');

                if (appSetting('categories_enabled', 'blog-' . $this->blog->id)) {

                    $aData['categories'] = $this->input->post('categories');
                }

                if (appSetting('tags_enabled', 'blog-' . $this->blog->id)) {

                    $aData['tags'] = $this->input->post('tags');
                }

                //  Are we running in preview mode?
                if (!empty($bIsPreview)) {

                    //  Previewing, set the preview tables and create a new one
                    $aData['blog_id'] = $this->blog->id;
                    $this->blog_post_model->usePreviewTables(true);
                    $iPostId = $this->blog_post_model->create($aData);

                } else {

                    //  Normal behaviour
                    $iPostId = $this->blog_post_model->create($aData);
                }

                if (!empty($iPostId)) {

                    //  Behave slightly differently depending on whether we're previewing or not
                    if (empty($bIsPreview)) {

                        //  Update admin changelog
                        $this->oChangeLogModel->add(
                            'created',
                            'a',
                            'blog post',
                            $iPostId,
                            $aData['title'],
                            'admin/blog/post/edit/' . $this->blog->id . '/' . $iPostId
                        );

                        $this->session->set_flashdata('success', ucfirst($this->data['postName']) . ' was created.');
                        $sRedirectUrl = 'admin/blog/post/edit/' . $this->blog->id . '/' . $iPostId;

                    } else {

                        $sRedirectUrl = $this->blog->url . '/preview/' . $iPostId;
                    }

                    redirect($sRedirectUrl);

                } else {

                    $this->data['error']  = 'An error occurred and the post could not be created. ';
                    $this->data['error'] .= $this->blog_post_model->lastError();
                }

            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Load Categories and Tags
        if (appSetting('categories_enabled', 'blog-' . $this->blog->id)) {

            $aData            = array();
            $aData['where']   = array();
            $aData['where'][] = array('column' => 'blog_id', 'value' => $this->blog->id);

            $this->data['categories'] = $this->blog_category_model->getAll(null, null, $aData);
        }

        if (appSetting('tags_enabled', 'blog-' . $this->blog->id)) {

            $aData            = array();
            $aData['where']   = array();
            $aData['where'][] = array('column' => 'blog_id', 'value' => $this->blog->id);

            $this->data['tags'] = $this->blog_tag_model->getAll(null, null, $aData);
        }

        // --------------------------------------------------------------------------

        //  Load other data
        $oCdn                            = Factory::service('Cdn', 'nails/module-cdn');
        $this->data['associations']      = $this->blog_model->getAssociations();
        $this->data['cdnUrlScaleScheme'] = $oCdn->urlScaleScheme();

        // --------------------------------------------------------------------------

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->library('uploadify');
        $oAsset->library('MUSTACHE');
        $oAsset->load('moment/moment.js', 'NAILS-BOWER');
        $oAsset->load('admin.post.edit.min.js', 'nails/module-blog');

        // --------------------------------------------------------------------------

        $sInlineJs  = 'var _EDIT;';
        $sInlineJs .= '$(function()';
        $sInlineJs .= '{';
        $sInlineJs .= '    _EDIT = new NAILS_Admin_Blog_Create_Edit(\'CREATE\');';
        $sInlineJs .= '    _EDIT.init(' . $this->blog->id . ', "' . $oCdn->generateApiUploadToken() . '");';
        $sInlineJs .= '});';

        $oAsset->inline($sInlineJs, 'JS');

        // --------------------------------------------------------------------------

        Helper::loadView('edit');
    }
1321461
public function create() {
        // Is this user allowed to do this?
        if (!$this->repository->isUserAllowed('create'))
        {
            Session::flash('status_code', 400 );
            $message = "You are not allowed to create ".$this->model->table;
            Session::flash('message', $message);
            return view('formhandling::warnings/' . config('lasallecmsadmin.admin_template_name') . '/user_not_allowed', [
                'package_title'        => $this->model->package_title,
                'table_type_plural'    => $this->model->table,
                'table_type_singular'  => strtolower($this->model->model_class),
                'resource_route_name'  => $this->model->resource_route_name,
                'HTMLHelper'           => HTMLHelper::class,
            ]);
        }

        // Specifically for Post Updates
        if (empty(Input::get('post_id'))) {
            $post_id = 0;
            //$related_table

        } else {

            $post_id = Input::get('post_id');

            if ( (int) $post_id < 1 )
            {
                // flash message with redirect
                Session::flash('status_code', 400 );
                $message = 'Please initiate the creation of a new update for your post by clicking the icon ';
                $message .= 'in the row of the post you want to update.';
                Session::flash('message', $message);
                return Redirect::route('admin.'.$this->model->resource_route_name.'.index');
            }
        }

        // Are there mandatory related tables that have no records? If so, can't create/edit
        $isNotNullableRelatedTablesWithNoRecords = $this->repository->isNotNullableRelatedTablesWithNoRecords($this->getFieldList());

        if ($isNotNullableRelatedTablesWithNoRecords['mandatory_no_records'])
        {
            Session::flash('status_code', 400 );
            $message  = "You are not allowed to create ".HTMLHelper::pluralToSingular($this->model->table)." because ";
            $message .= "there are no enabled records in the ";

            if ( !empty($isNotNullableRelatedTablesWithNoRecords['field']['alternate_form_name']) )
            {
                $message .= $isNotNullableRelatedTablesWithNoRecords['field']['alternate_form_name'];
            } else {
                $message .= $isNotNullableRelatedTablesWithNoRecords['field']['name'];
            }

            $message .= ' table. You must add enabled records to the "';
            $message .= $isNotNullableRelatedTablesWithNoRecords['field']['related_table_name'];

            $message .= '" table first!';
            Session::flash('message', $message);
            return Redirect::route('admin.'.$this->model->resource_route_name.'.index');
        }

        return view('formhandling::adminformhandling/' . config('lasallecmsadmin.admin_template_name') . '/create',
        [
            'post_id'                      => $post_id,
            'repository'                   => $this->repository,
            'package_title'                => $this->model->package_title,
            'table_name'                   => $this->model->table,
            'model_class'                  => $this->model->model_class,
            'resource_route_name'          => $this->model->resource_route_name,
            'field_list'                   => $this->getFieldList(),
            'namespace_formprocessor'      => $this->model->namespace_formprocessor,
            'classname_formprocessor_create' => $this->model->classname_formprocessor_create,
            'DatesHelper'                  => DatesHelper::class,
            'HTMLHelper'                   => HTMLHelper::class,
            'carbon'                       => Carbon::class,
            'Config'                       => Config::class,
            'Form'                         => Form::class,
            'admin_size_input_text_box'    => Config::get('lasallecmsadmin.admin_size_input_text_box'),
        ]);
    }
489161
@Override
	@Transactional(enabled = false)
	public CPMeasurementUnit createCPMeasurementUnit(long CPMeasurementUnitId) {
		return cpMeasurementUnitPersistence.create(CPMeasurementUnitId);
	}
390009
public function newAction()
    {
        $entity = new Feature();

        if ($this->getRequest()->query->has('category')) {
            $em = $this->getDoctrine()->getManager();

            $category = $em->getRepository('EcommerceBundle:Category')->
                find($this->getRequest()->query->get('category'));

            $entity->setCategory($category);
        }

        $form   = $this->createForm(new FeatureType(), $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
279280
public function createMetricAction()
    {
        $metricData = Binput::get('metric');

        try {
            execute(new CreateMetricCommand(
                $metricData['name'],
                $metricData['suffix'],
                $metricData['description'],
                $metricData['default_value'],
                $metricData['calc_type'],
                $metricData['display_chart'],
                $metricData['places'],
                $metricData['default_view'],
                $metricData['threshold'],
                0, // Default order
                $metricData['visible']
            ));
        } catch (ValidationException $e) {
            return cachet_redirect('dashboard.metrics.create')
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('dashboard.metrics')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
    }
293562
protected function crudCreate(Request $request = null)
    {
        try{
            
            $entity = $this->getEntity();
            $form = $this->createAndBindForm($request, $this->getEntityType() , $entity);
            $page = static::NEW_VIEW;
            
            if ($form->isValid()) {
                $this->saveEntity($entity);                
                if($request->get('_loop_create')){
                    $form = $this->createForm($this->getEntityType(), $this->getEntity());
                }else{
                    $page = static::SHOW_VIEW;
                    $form = $this->createDeleteForm($entity->getId());
                }
                $form = $form->createView();
                return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
            }
            $form = $form->createView();
            return $this->success($page, $this->commonsResponseVars(compact('entity','form')));
            
        }catch(\Exception $e){
          return $this->failure($e);
        }
    }
630070
public function create($type, $set, $sku, $productData, $storeView = null)
    {
        return $this->__createAction('catalog_product.create', func_get_args());
    }
546376
public function actionCreate()
	{
		$model=new Post;
		if(isset($_POST['Post']))
		{
			$model->attributes=$_POST['Post'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
701406
public function create() {
        if ($this->overrideAction('create')) {
            return;
        }

        $this->AdminToolbar->setBelongsToData($this->Model);
        $this->AdminToolbar->setHabtmData($this->Model);

        if ($this->request->is('post')) {
            $data = $this->AdminToolbar->getRequestData();
            $this->Model->create();

            if ($this->Model->saveAll($data, array('validate' => 'first', 'atomic' => true, 'deep' => true))) {
                $this->Model->set($data);
                $this->AdminToolbar->logAction(ActionLog::CREATE, $this->Model, $this->Model->id);

                $this->AdminToolbar->setFlashMessage(__d('admin', 'Successfully created a new %s', mb_strtolower($this->Model->singularName)));
                $this->AdminToolbar->redirectAfter($this->Model);

            } else {
                $this->AdminToolbar->setFlashMessage(__d('admin', 'Failed to create a new %s', mb_strtolower($this->Model->singularName)), 'is-error');
            }
        }

        $this->overrideView('create');
    }
904696
public function create(
        RestCompanyBusinessUnitsRequestAttributesTransfer $restCompanyBusinessUnitsRequestAttributesTransfer
    ): RestCompanyBusinessUnitsResponseTransfer {
        $companyBusinessUnitTransfer = new CompanyBusinessUnitTransfer();

        foreach ($this->companyBusinessUnitMapperPlugins as $companyBusinessUnitMapperPlugin) {
            $companyBusinessUnitTransfer = $companyBusinessUnitMapperPlugin->map(
                $restCompanyBusinessUnitsRequestAttributesTransfer,
                $companyBusinessUnitTransfer
            );
        }

        try {
            $companyBusinessUnitResponseTransfer = $this->companyBusinessUnitFacade->create($companyBusinessUnitTransfer);
        } catch (PropelException $e) {
            return $this->createCompanyBusinessUnitDataInvalidErrorResponse();
        }

        if (!$companyBusinessUnitResponseTransfer->getIsSuccessful()) {
            return $this->createCompanyBusinessUnitDataInvalidErrorResponse();
        }

        return $this->createCompanyBusinessUnitResponseTransfer(
            $companyBusinessUnitResponseTransfer->getCompanyBusinessUnitTransfer()
        );
    }
1036366
public function createAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth(AdminResources::MODULE, Team::getModuleCode(),
                AccessManager::CREATE)
        ) {
            return $response;
        }

        // Create the Creation Form
        $creationForm = $this->getCreationForm($this->getRequest());

        $con = Propel::getConnection();
        $con->beginTransaction();

        try {
            // Check the form against constraints violations
            $form = $this->validateForm($creationForm, "POST");
            // Get the form field values
            $data = $form->getData();

            $createdObject = $this->getService()->createFromArray($data, $this->getCurrentEditionLocale());


            // Substitute _ID_ in the URL with the ID of the created object
            $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());

            $con->commit();

            // Redirect to the success URL
            return $this->generateRedirect($successUrl);

        } catch (FormValidationException $ex) {
            $con->rollBack();
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            $con->rollBack();
            // Any other error
            $error_msg = $ex->getMessage();
        }
        if (false !== $error_msg) {
            $this->setupFormErrorContext(
                $this->getTranslator()->trans("%obj creation", ['%obj' => static::CONTROLLER_ENTITY_NAME]),
                $error_msg,
                $creationForm,
                $ex
            );

            // At this point, the form has error, and should be redisplayed.
            return $this->getListRenderTemplate();
        }

    }
585633
public function newAction()
        {
            $oUser = new User();
            $form   = $this->createCreateForm($oUser);

            return $this->render('SlashworksBackendBundle:User:new.html.twig', array(
                'entity' => $oUser,
                'form'   => $form->createView(),
            ));
        }
1092205
public function saveUnit(Unit $unit)
    {
        $propelUnit = UnitQuery::create()->findOneByDomainAndKey($unit->getDomain(), $unit->getKey());
        if (!$propelUnit) {
            $propelUnit = new PropelUnit();
        }
        $propelUnit->updateFromModel($unit);
        $propelUnit->save();
    }
1014978
def create(label)
      create_atomic(label.to_s) or create_composite(label.to_s) or raise MeasurementError.new("Unit '#{label}' not found")
    end
135655
public function create()
    {
        /**
         * @var Order $order
         */
        $classNamespace = $this->getEntityNamespace();
        $order = new $classNamespace();
        $order
            ->setQuantity(0)
            ->setWidth(0)
            ->setHeight(0)
            ->setWidth(0)
            ->setWeight(0)
            ->setCreatedAt($this->now())
            ->setPurchasableAmount($this->createZeroAmountMoney())
            ->setAmount($this->createZeroAmountMoney())
            ->setCouponAmount($this->createZeroAmountMoney())
            ->setShippingAmount($this->createZeroAmountMoney());

        $paymentStateLineStack = $this
            ->paymentMachineManager
            ->initialize(
                $order,
                StateLineStack::create(
                    new ArrayCollection(),
                    null
                ),
                'Order not paid'
            );

        $order->setPaymentStateLineStack($paymentStateLineStack);

        $shippingStateLineStack = $this
            ->shippingMachineManager
            ->initialize(
                $order,
                StateLineStack::create(
                    new ArrayCollection(),
                    null
                ),
                'Preparing Order'
            );

        $order->setShippingStateLineStack($shippingStateLineStack);

        return $order;
    }
459330
public function create()
	{
		$arrNodes = false;

		if ($this->insideRoot)
		{
			$objContent = \ContentModel::findById($this->data->pid);

			$rootId = Controller::getRootPageId($objContent->ptable, $objContent->pid);

			if (null !== $rootId)
			{
				$objPage = \PageModel::findWithDetails($rootId);

				if ($this->insideLang || empty($objPage->domain))
				{
					$arrNodes = array($rootId);
				}
				else
				{
					$arrNodes = (array) \PageModel::findByDns($objPage->domain)->fetchEach('id');
				}
			}
		}
		
		if ($this->multiArticle)
		{
			$this->generateDCA('multiArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'multiple'		=>	true,				
					'fieldType'		=>	'checkbox', 
					'orderField'	=>	$this->virtualFieldName('orderArticle'),
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
				'load_callback'		=> array
				(
					array('tl_content_contentblocks', 'prepareOrderPageValue'),
				),
				'save_callback'		=> array
				(
					array('tl_content_contentblocks', 'saveOrderPageValue'),
				),
			));
		}
		else
		{
			$this->generateDCA('singleArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'fieldType'		=>	'radio', 
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
			));
		}
	}