當前位置: 首頁>>代碼示例>>PHP>>正文


PHP self::create方法代碼示例

本文整理匯總了PHP中self::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP self::create方法的具體用法?PHP self::create怎麽用?PHP self::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在self的用法示例。


在下文中一共展示了self::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createFromExercise

 /**
  * Import relevant properties from given exercise
  *
  * @param ilObjExercise $a_test
  * @return object
  */
 public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("exercise");
     $newObj = new self();
     $newObj->setTitle($a_exercise->getTitle());
     $newObj->setDescription($a_exercise->getDescription());
     include_once "Services/Tracking/classes/class.ilLPMarks.php";
     $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
     $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise));
     $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
     // remove if certificate works
     $newObj->create();
     return $newObj;
 }
開發者ID:Walid-Synakene,項目名稱:ilias,代碼行數:39,代碼來源:class.ilObjExerciseVerification.php

示例2: add

 public static function add($data)
 {
     $model = new self();
     $data['pid'] = 0;
     $data['auth'] = ' ';
     return $model->create($data);
 }
開發者ID:Crocodile26,項目名稱:php-1,代碼行數:7,代碼來源:Role.php

示例3: record

 public static function record($type, $user_id)
 {
     $active = new self();
     $active->user_id = $user_id;
     $active->type = $type;
     $active->create();
 }
開發者ID:sysatom,項目名稱:workflow,代碼行數:7,代碼來源:UserActive.php

示例4: createSupportGroup

 /**
  * Wrapper for creating a support group.
  * It will check if the support group doesn't exist yet, if the tag or name already exists then NAME_TAKEN  or TAG_TAKEN will be returned.
  * If the name is bigger than 20 characters or smaller than 4 and the tag greater than 7 or smaller than 2 a SIZE_ERROR will be returned.
  * Else it will return SUCCESS
  * @return a string that specifies if it was a success or not (SUCCESS, SIZE_ERROR, NAME_TAKEN or TAG_TAKEN )
  */
 public static function createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password)
 {
     //error_log( "Error at line " . __LINE__ . " in file " . __FILE__);
     if (strlen($name) <= 21 && strlen($name) >= 4 && strlen($tag) <= 8 && strlen($tag) >= 2) {
         $notExists = self::supportGroup_EntryNotExists($name, $tag);
         //error_log( "Error at line " . __LINE__ . " in file " . __FILE__);
         if ($notExists == "SUCCESS") {
             $sGroup = new self();
             $values = array('Name' => $name, 'Tag' => $tag, 'GroupEmail' => $groupemail, 'IMAP_MailServer' => $imap_mailserver, 'IMAP_Username' => $imap_username, 'IMAP_Password' => $imap_password);
             $sGroup->setName($values['Name']);
             $sGroup->setTag($values['Tag']);
             $sGroup->setGroupEmail($values['GroupEmail']);
             $sGroup->setIMAP_MailServer($values['IMAP_MailServer']);
             $sGroup->setIMAP_Username($values['IMAP_Username']);
             //encrypt password!
             global $cfg;
             $crypter = new MyCrypt($cfg['crypt']);
             $enc_password = $crypter->encrypt($values['IMAP_Password']);
             $sGroup->setIMAP_Password($enc_password);
             $sGroup->create();
             //error_log( "Error at line " . __LINE__ . " in file " . __FILE__);
         } else {
             //error_log( "Error at line " . __LINE__ . " in file " . __FILE__);
             //return NAME_TAKEN  or TAG_TAKEN
             return $notExists;
         }
     } else {
         //error_log( "Error at line " . __LINE__ . " in file " . __FILE__);
         //RETURN ERROR that indicates SIZE
         return "SIZE_ERROR";
     }
 }
開發者ID:ryzom,項目名稱:ryzomcore,代碼行數:39,代碼來源:support_group.php

示例5: createFromTest

 /**
  * Import relevant properties from given test
  *
  * @param ilObjTest $a_test
  * @return object
  */
 public static function createFromTest(ilObjTest $a_test, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("wsp");
     $newObj = new self();
     $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\"");
     $newObj->setDescription($a_test->getDescription());
     $active_id = $a_test->getActiveIdOfUser($a_user_id);
     $pass = ilObjTest::_getResultPass($active_id);
     $date = $a_test->getPassFinishDate($active_id, $pass);
     $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test));
     $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
 }
開發者ID:khanhnnvn,項目名稱:ilias_E-learning,代碼行數:37,代碼來源:class.ilObjTestVerification.php

示例6: add

 public static function add($data)
 {
     $model = new self();
     unset($data['repassword']);
     $data['status'] = 1;
     return $model->create($data);
 }
開發者ID:Crocodile26,項目名稱:php-1,代碼行數:7,代碼來源:Operator.php

示例7: render

 /**
  * @param string          $format
  * @param OutputInterface $output
  * @param array           $rows
  */
 public static function render($format, OutputInterface $output, array $rows)
 {
     $factory = new self();
     if (!($renderer = $factory->create($format))) {
         throw new InvalidArgumentException(sprintf('Unknown format %s, known formats are: %s', var_export($format)), implode(',', self::getFormats()));
     }
     $renderer->render($output, $rows);
 }
開發者ID:jsiefer,項目名稱:n98-magerun,代碼行數:13,代碼來源:RendererFactory.php

示例8: getObjectManager

 /**
  * Get MTF Object Manager instance
  *
  * @return ObjectManager
  */
 public static function getObjectManager()
 {
     if (!($objectManager = ObjectManager::getInstance())) {
         $objectManagerFactory = new self();
         $objectManager = $objectManagerFactory->create();
     }
     return $objectManager;
 }
開發者ID:vasiljok,項目名稱:magento2,代碼行數:13,代碼來源:ObjectManagerFactory.php

示例9: get

 public static function get()
 {
     if (!isset(self::$driver)) {
         $i = new self();
         self::$driver = $i->create();
     }
     return self::$driver;
 }
開發者ID:fliglio,項目名稱:borg,代碼行數:8,代碼來源:MockCollectiveDriverFactory.php

示例10: add

 public static function add($params)
 {
     $handle = new self();
     foreach ($params as $key => $value) {
         $handle->{$key} = $value;
     }
     $handle->create($params);
 }
開發者ID:Oogieboogie23,項目名稱:Division-Tracker,代碼行數:8,代碼來源:MemberHandle.php

示例11: instance

 /**
  * @return \Doctrine\ORM\EntityManager
  */
 public static function instance()
 {
     if (is_null(self::$entityManagerInstance)) {
         $entityManager = new self();
         self::$entityManagerInstance = $entityManager->create();
     }
     return self::$entityManagerInstance;
 }
開發者ID:kohana,項目名稱:doctrine,代碼行數:11,代碼來源:EntityManager.php

示例12: createOrUpdate

 public static function createOrUpdate($siteId, $links)
 {
     // dd( $links );
     $links->filter(function ($link) use($siteId) {
         return self::isSameHost($link, $siteId);
     })->each(function ($link) use($siteId) {
         $saveWebpage = new self();
         $saveWebpage->create($siteId, $link);
     });
 }
開發者ID:SimZal,項目名稱:laracrawl,代碼行數:10,代碼來源:SaveWebpage.php

示例13: set

 /**
  * @param $name
  * @param $value
  */
 public static function set($name, $value)
 {
     $obj = new self($name);
     $obj->setValue($value);
     if (self::where(array('name' => $name))->hasSets()) {
         $obj->update();
     } else {
         $obj->create();
     }
 }
開發者ID:arlendotcn,項目名稱:ilias,代碼行數:14,代碼來源:class.arConfig.php

示例14: createFromCollection

 /**
  * Batch create of properties from variables array
  * @param VariableCollection $variableCollection Array of variable definition
  * @return array Array of created properties
  */
 public static function createFromCollection(VariableCollection $variableCollection)
 {
     $properties = [];
     /** @var Variable $variable */
     foreach ($variableCollection as $variable) {
         $property = new self($variable->getName(), $variable->getType(), $variable->getVisibility());
         $properties[] = $property->create();
     }
     return $properties;
 }
開發者ID:gefud,項目名稱:gefud,代碼行數:15,代碼來源:EntityPropertyGenerator.php

示例15: createSubFolders

 private function createSubFolders()
 {
     $ok = true;
     foreach ($this->subFolders as $folder) {
         $dir = new self($this->getPath() . $folder);
         if (!$dir->create()) {
             $ok = false;
         }
     }
     return $ok;
 }
開發者ID:sergiowebmaster,項目名稱:CleanCode,代碼行數:11,代碼來源:CleanCodeDir.php


注:本文中的self::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。