Skip to content

Instantly share code, notes, and snippets.

<?php
namespace app\modules\MY-MODULE;
class Module extends \yii\base\Module
{
public $controllerNamespace = 'app\modules\MY-MODULE\controllers';
public function init()
{
<?php
/* @var $xml app\modules\yiipass\services\xml */
$xml = \Yii::$app->getModule('MY-MODULE')->get('xml');
<?php
namespace app\modules\MY-MODULE;
class Module extends \yii\base\Module
{
public $controllerNamespace = 'app\modules\MY-MODULE\controllers';
public function init()
{
<?php
namespace app\modules\MY-MODULE\assets;
use yii\web\AssetBundle;
class MyModuleAsset extends AssetBundle
{
// the alias to your assets folder in your file system
public $sourcePath = '@yiipass-assets';
<?php
// that class is usually used, if you work with html in your view.
use yii\helpers\Html;
// here comes your Yii2 asset's class!
use app\modules\YOUR-MODULE\assets\YOUR-ASSER-CLASS;
// now Yii puts your css and javascript files into your view's html.
MyModuleAsset::register($this);
@jepster
jepster / my.html
Created July 31, 2015 06:16
my.html
<script src="/assets/3598bbc6/js/YOUR-JavaScriptFile.js"></script>
@jepster
jepster / IN-YOUR-CONTROLLER-yii-row-check.php
Created August 1, 2015 12:52
For usage in your controller.
<?php
$provider_ids = Provider::find()
->select(['id'])
->where(['parent_id' => $parent_provider_id]);
$num_providers = $provider_ids->count();
if($num_providers > 0){
$arr_provider = $provider_ids
gaya.info.yml:
name: Gaia
type: theme
description: 'A starter theme which is based on the Drupal core template files.'
package: Core
version: 8.x-1.0
core: 8.x
libraries:
- gaia/global-styling
<?php
$dom = new \DOMDocument('1.0', 'UTF-8');
// PHP will output warnings about non-standard HTML. Suppress it by "@".
@$dom->loadHTML($source);
// Iterate over all link-elements.
foreach ($dom->getElementsByTagName('link') as $node) {
// Copy the element to be able to replace it.
$updated_element = $node;
$href_value = $updated_element->getAttribute( 'href' );