Create cache entry if a contact was created, used for duplicate checking and limits.

@throws \Exception
330818
private function createCache()
    {
        if ($this->valid && $this->contact->getId()) {
            $this->getCacheModel()->setContact($this->contact)
                ->setContactSource($this->contactSource)
                ->create($this->campaignId);
        }
    }
771105
public static function create() 
    {
		$alias = func_get_arg(0);
		$name = func_get_arg(1);
		
        try {
            $m = self::getByAlias($alias);
        } catch (\Exception $e) {}
        
        if ($m) throw new Exception\CMS('Меню c таким алиасом уже существует.');
        
        self::getDbConnection()->insert('menus', array(
			'alias' => $alias,
			'name'  => $name
		));
  		return self::getById( self::getDbConnection()->lastInsertId() );
  	}
775631
protected static function _initializeCache()
    {
        if ( !static::$_options[CoreSettings::ENABLE_CACHE] )
        {
            return false;
        }

        //  Try memcached
        try
        {
            return static::$_cache = Flexistore::createMemcachedStore( array('host' => 'localhost') );
        }
        catch ( \Exception $_ex )
        {
        }

        //  Try memcache
        try
        {
            return static::$_cache = Flexistore::createMemcacheStore( array('host' => 'localhost') );
        }
        catch ( \Exception $_ex )
        {
        }

        //  Find me a cache path!
        if ( false === ( $_path = static::_getCachePath() ) )
        {
            return false;
        }

        //  Try files
        return static::$_cache = Flexistore::createFileStore( $_path );
    }
1283353
public function afterCreate()
    {
        //setup the user notificatoin setting
        $companySettings = new CompanySettings();
        $companySettings->company_id = $this->getId();
        $companySettings->name = 'notifications';
        $companySettings->value = $this->user->email;
        if (!$companySettings->save()) {
            throw new Exception(current($companySettings->getMessages()));
        }

        //multi user asociation
        $usersAssociatedCompany = new UsersAssociatedCompany();
        $usersAssociatedCompany->users_id = $this->user->getId();
        $usersAssociatedCompany->company_id = $this->getId();
        $usersAssociatedCompany->identify_id = $this->user->getId();
        $usersAssociatedCompany->user_active = 1;
        $usersAssociatedCompany->user_role = 'admin';
        if (!$usersAssociatedCompany->save()) {
            throw new Exception(current($usersAssociatedCompany->getMessages()));
        }

        //now that we setup de company and associated with the user we need to setup this as its default company
        if (!UserConfig::findFirst(['conditions' => 'users_id = ?0 and name = ?1', 'bind' => [$this->user->getId(), self::DEFAULT_COMPANY]])) {
            $userConfig = new UserConfig();
            $userConfig->users_id = $this->user->getId();
            $userConfig->name = self::DEFAULT_COMPANY;
            $userConfig->value = $this->getId();

            if (!$userConfig->save()) {
                throw new Exception(current($userConfig->getMessages()));
            }
        }
    }
1135090
protected function createEntry()
    {
        $arrColumns = $this->getTableColumns();
        $arrColumnNames = [];
        $arrColumnTypes = [];
        
        foreach ($arrColumns as $column) {
            $arrColumnNames[] = $column['Field'];
            $arrColumnTypes[] = $column['Type'];
        }
        
        $sql = 'INSERT INTO `'.$this->tableName.'` '
            . '(`'.implode('`, `', $arrColumnNames).'`) '
            . 'VALUES '
            . '(:'.implode(', :', $arrColumnNames).')';
        
        $arrInsert = [];
        for ($i = 0; $i < count($arrColumnNames); $i++) {
            $name = $arrColumnNames[$i];
            $value = isset($this->$name)?$this->$name:"";
            if (substr($arrColumnTypes[$i], 0, 3) == 'int') {
                $value = (int) $value;
            } elseif ($arrColumnTypes[$i] == 'datetime') {
                $value = strftime("%Y-%m-%d %H:%M:%S", strtotime($value));
            }
            $arrInsert[':'.$name] = $value;
        }
        
        
        $this->db->beginTransaction();
        $stmt = $this->db->prepare($sql);
        
        try {
            $stmt->execute($arrInsert);
            $this->db->commit();
        } catch (PDOException $ex) {
            $this->db->rollBack();
            $this->log->critical(
                "Could not save to mysql".PHP_EOL
                .$sql.PHP_EOL
                .print_r($arrInsert, true).PHP_EOL
                .$ex->getMessage()
            );
        }
    }
854099
protected function after_create() {
        $cache = \cache::make('tool_dataprivacy', 'purpose');
        $cache->set($this->get('id'), $this->to_record());
    }
228976
public function create()
    {
        if (!userHasPermission('admin:invoice:customer:create')) {
            unauthorised();
        }

        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            try {

                $this->formValidation();
                $oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
                if (!$oCustomerModel->create($this->prepPostData())) {
                    throw new NailsException('Failed to create item. ' . $oCustomerModel->lastError(), 1);
                }

                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData('success', 'Item created successfully.');
                redirect('admin/invoice/customer');

            } catch (\Exception $e) {
                $this->data['error'] = $e->getMessage();
            }
        }

        $this->data['page']->title = 'Create customer';
        Helper::loadView('edit');
    }
33107
protected function init()
    {
        try {
            $lastUpdate = $this->initFromFiles();
        } catch (ShopgateLibraryException $e) {
            // If this fails with an exception we have a most likely permanent problem.
            // In that case the lists _MUST NOT_ be fetched from the API as chances are high this would happen for
            // every request to the merchant's desktop site.
            return;
        }

        if ($this->disableUpdate || !$this->expired($lastUpdate)) {
            return;
        }

        try {
            $this->update();
        } catch (Exception $e) {
            // if fetching from API fails, try again in 5 minutes; meanwhile use the cached keywords
            $this->saveAllKeywordsToFiles($newUpdateTimestamp = (time() - ($this->cacheTimeout * 3600)) + 300);
        }
    }
1192426
public function create()
    {
        $this->getIdHandler()->generateId();

        $this->values = array();

        $this->firstTrace = time();
        $this->updateLastTrace();

        $this->requestsCount = 1;
        $this->regenerationTrace = time();

        $this->fingerprint = $this->generateFingerprint();

        $this->opened = true;

        return $this->opened;
    }
1232096
private function _create_cache_dir()
    {
        if (! file_exists($this->config['cache_dir'])) {
            try {
                mkdir($this->config['cache_dir'], 0755, TRUE);
            } catch (Exception $e) {
                throw $e;
            }
        }
        
        // Set the cache dir
        $this->cache_dir = $this->config['cache_dir'];
    }
328829
private void createAddContactSubForm() {
		add(new WHeading(HeadingLevel.H3, "Add a new contact"));

		WButton addBtn = new WButton("Add");
		addBtn.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				addNewContact();
			}
		});
		addBtn.setImage("/image/address-book-new.png");
		newNameField.setDefaultSubmitButton(addBtn);

		WContainer container = new WContainer();
		container.add(newNameField);
		container.add(addBtn);

		WFieldLayout layout = new WFieldLayout();
		add(layout);
		layout.addField("New contact name", container);
		add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField}));
	}
1192423
private function createTable(): void
    {
        $statement = 'CREATE TABLE tests (
                          id INTEGER PRIMARY KEY,
                          command TEXT NOT NULL UNIQUE,
                          file_name TEXT NOT NULL,
                          reserved_by_process_id INTEGER,
                          completed INTEGER DEFAULT 0
                        )';

        if ($this->db->exec($statement) === false) {
            throw new Exception('Error while creating sqlite database table: ' . $this->db->errorCode());
        }
    }
805902
public function build(): RequestEntriesRequest
	{
		$instance = new RequestEntriesRequest();
		if ($this->cacheId === null) {
			throw new BuilderException('Property [cacheId] is required.');
		}
		$instance->cacheId = $this->cacheId;
		if ($this->skipCount === null) {
			throw new BuilderException('Property [skipCount] is required.');
		}
		$instance->skipCount = $this->skipCount;
		if ($this->pageSize === null) {
			throw new BuilderException('Property [pageSize] is required.');
		}
		$instance->pageSize = $this->pageSize;
		$instance->pathFilter = $this->pathFilter;
		return $instance;
	}
727553
public function create_lockfile($contents=null) {
		if(!$this->is_lockfile_present()) {
			$retval = $this->fsObj->create_file($this->get_lockfile());
			
			if(!is_null($contents)) {
				$this->fsObj->write($contents);
			}
		}
		else {
			throw new exception(__METHOD__ .": lockfile (". $this->lockFile .") already present");
		}
		
		return($retval);
	}
748383
protected function createByteCache(): void
    {
        if (!empty($this->byteCache)) {
            return;
        }

        if (empty($this->stream)) {
            throw new MimeDetectorException('No file provided.');
        }

        foreach (str_split($this->stream) as $i => $char) {
            $this->byteCache[$i] = ord($char);
        }

        $this->byteCacheLen = count($this->byteCache);
    }
595643
public function cache()
    {
        foreach($this->getRoutes() as $key => $r) {
            if (!is_string($r['callback'])) {
                throw new Exception(sprintf('Routes cannot contain a Closure/Function callback while caching.'));
            }
        }

        $cacheContent = '<?php return '.var_export($this->getRoutes(), true).';' . PHP_EOL;
        if (false === file_put_contents($this->cacheFile, $cacheContent)) {
            throw new Exception(sprintf('Routes cache file could not be written.'));
        }

        return true;
    }
497604
protected function createEntry()
    {
        $entry = new Entry();
        $entry->setVisible(false)
              ->setName($this->name);
        $this->setEntry($entry);
        return $entry;
    }