本文整理汇总了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;
}
示例2: add
public static function add($data)
{
$model = new self();
$data['pid'] = 0;
$data['auth'] = ' ';
return $model->create($data);
}
示例3: record
public static function record($type, $user_id)
{
$active = new self();
$active->user_id = $user_id;
$active->type = $type;
$active->create();
}
示例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";
}
}
示例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();
}
}
示例6: add
public static function add($data)
{
$model = new self();
unset($data['repassword']);
$data['status'] = 1;
return $model->create($data);
}
示例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);
}
示例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;
}
示例9: get
public static function get()
{
if (!isset(self::$driver)) {
$i = new self();
self::$driver = $i->create();
}
return self::$driver;
}
示例10: add
public static function add($params)
{
$handle = new self();
foreach ($params as $key => $value) {
$handle->{$key} = $value;
}
$handle->create($params);
}
示例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;
}
示例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);
});
}
示例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();
}
}
示例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;
}
示例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;
}