This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require(__DIR__ . '/vendor/autoload.php'); | |
use yii\helpers\ArrayHelper; | |
use yii\helpers\VarDumper; | |
$fooArray = [ | |
['name' => 'Han Solo', 'email' => 'han.solo@starwars.com'], | |
['name' => '', 'email' => 'luc.skywalker@starwars.com'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* EFastDbAuthManager class file | |
* | |
* This class inherit from and is an enhancement for CDbAuthManager class which lower the number of database queries. | |
* The main difference with the original class is that the authorization data are loaded once for all in a very a similar way to CPhpAuthManager. | |
* In short terms, this is a kind of mix between CDbAuthManager and CPhpAuthManager classes to get the best of both worlds. | |
* The class can also be used to cache the authorization data to achieve an even faster loading. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if(!isset($argv[1])) | |
die("Please, specify a file to process as argument\n"); | |
$file = $argv[1]; | |
if(!file_exists($file)) { | |
die("File $file does not exist\n"); | |
} | |
$pathinfo = pathinfo(realpath($file)); | |
$data = file_get_contents($file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$applicationsDataProvider = new \yii\data\ActiveDataProvider([ | |
'query' => $model->getRelation('relationName'), | |
'pagination' => [ | |
'pageParam' => 'apps_page' | |
] | |
]); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://host.name/_nodes?plugin=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set entry = craft.entries.slug('homepage').first() %} | |
{% redirect entry.workshopPages[0].url %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$schemaVersion = Craft::$app->getInstalledSchemaVersion(); | |
if (version_compare($schemaVersion, '3.2.0', '>=')) { | |
// Do something specific to Craft CMS 3.2 and upper | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class iOSPNGNormalizer | |
{ | |
public static function fix($filename, $destfilename = null) | |
{ | |
try { | |
$handle = fopen($filename, "rb"); | |
$oldPNG = fread($handle, filesize($filename)); | |
fclose($handle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// To put somewhere in a module, plugin or content migration | |
// Get the entry type to add the new field to | |
$entryType = Craft::$app->getSections()->getSectionByHandle('someSectionHandle')->entryTypes[0]; | |
$field = Craft::$app->getFields()->getFieldByHandle('someFieldHandle'); | |
// Get current fieldLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Event::on( | |
\craft\records\User::class, | |
\craft\records\User::EVENT_AFTER_UPDATE, | |
static function (\yii\db\AfterSaveEvent $event) { | |
$userRecord = $event->sender; | |
$user = Craft::$app->getUsers()->getUserById($userRecord->id); | |
$sites = Craft::$app->getSites(); | |
if ($user->isInGroup('user')) { |
OlderNewer