/**
  * @inheritdoc
  */
 private function __construct()
 {
     $installed = [];
     $installedJson = Yii::getAlias('@vendor') . '/composer/installed.json';
     if (true === file_exists($installedJson) && is_readable($installedJson)) {
         $installed = Json::decode(file_get_contents($installedJson));
         $compatibleTypes = Extension::getTypes();
         foreach ($installed as $i => $data) {
             if (true === isset($data['name']) && true === isset($compatibleTypes[$data['type']])) {
                 $installed[$data['name']] = $data;
             }
             unset($installed[$i]);
         }
     }
     $this->_set = $installed;
 }
 public function testInstalledGetType()
 {
     $data = ComposerInstalledSet::get()->getInstalled('fakedev2/yii2-fake-ext4');
     $type = ExtensionDataHelper::getType($data);
     $this->assertSame(4, count(ComposerInstalledSet::get()->getInstalled()));
     $this->assertSame('dotplant-extension', $type);
     $this->assertTrue(isset(Extension::getTypes()[$type]));
     return $data;
 }
Ejemplo n.º 3
0
            <div class="box-header clearfix">
                <h3 class="box-title pull-left">
                    <?php 
echo Yii::t('extensions-manager', 'Extensions search');
?>
                </h3>
                <div class="pull-right">
                    <?php 
echo Html::beginForm(['/extensions-manager/extensions/search'], 'GET', ['class' => 'form-inline']);
?>
                    <div class="form-group">
                        <?php 
echo Html::dropDownList('sort', Yii::$app->request->get('sort'), $sortBy, ['class' => 'form-control', 'prompt' => Yii::t('extensions-manager', 'Sort by')]);
?>
                        <?php 
echo Html::dropDownList('type', $type, Extension::getTypes(), ['class' => 'form-control', 'prompt' => Yii::t('extensions-manager', 'Extension type')]);
?>
                    </div>
                    <div class="input-group" style="width: 150px;">
                        <input type="text" name="query" value="<?php 
echo Yii::$app->request->get('query');
?>
"
                               class="form-control pull-right"
                               placeholder="Search">

                        <div class="input-group-btn">
                            <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                        </div>
                    </div>
                    <?php 
Ejemplo n.º 4
0
        </div>
    </div>
    <div class="col-md-9">
        <div class="extensions-controller__list-extensions box box-solid">
            <div class="box-header clearfix">
                <h3 class="box-title pull-left">
                    <?php 
echo Yii::t('extensions-manager', 'Installed extensions');
?>
                </h3>
            </div>
        <?php 
echo GridView::widget(['id' => 'extensions-list', 'dataProvider' => $dataProvider, 'layout' => $gridTpl, 'tableOptions' => ['class' => 'table table-bordered table-hover table-responsive'], 'pager' => ['options' => ['class' => 'pagination pull-right']], 'columns' => [['label' => Yii::t('extensions-manager', 'Name'), 'attribute' => 'composer_name', 'content' => function ($data) use($nameBlockTpl, $composerSet) {
    $name = ExtensionDataHelper::getLocalizedDataField($composerSet->getInstalled($data["composer_name"]), Extension::TYPE_YII, 'name');
    $description = ExtensionDataHelper::getLocalizedDataField($composerSet->getInstalled($data["composer_name"]), Extension::TYPE_YII, 'description');
    $activateButton = 0 == $data['is_active'] ? Yii::$app->user->can('extensions-manager-activate-extension') ? Html::button(Yii::t('extensions-manager', 'Activate'), ['class' => 'btn btn-success btn-xs', 'data-action' => 'run-ext-task', 'data-ext-task' => ExtensionsManager::ACTIVATE_DEFERRED_TASK, 'data-package-name' => $data["composer_name"]]) : '' : (Yii::$app->user->can('extensions-manager-deactivate-extension') ? Html::button(Yii::t('extensions-manager', 'Deactivate'), ['class' => 'btn btn-warning btn-xs', 'data-action' => 'run-ext-task', 'data-ext-task' => ExtensionsManager::DEACTIVATE_DEFERRED_TASK, 'data-package-name' => $data["composer_name"]]) : '');
    $removeButton = $data['is_core'] == 0 && Yii::$app->user->can('extensions-manager-uninstall-extension') ? Html::button(Yii::t('extensions-manager', 'Uninstall'), ['class' => 'btn btn-danger btn-xs', 'data-action' => 'run-ext-task', 'data-ext-task' => ExtensionsManager::UNINSTALL_DEFERRED_TASK, 'data-package-name' => $data["composer_name"]]) : '';
    $buttons = $removeButton . Html::button(Yii::t('extensions-manager', 'Check updates'), ['class' => 'btn btn-warning btn-xs', 'data-action' => 'run-ext-task', 'data-ext-task' => ExtensionsManager::CHECK_UPDATES_DEFERRED_TASK, 'data-package-name' => $data["composer_name"]]) . Html::button(Yii::t('extensions-manager', 'Details') . '  ' . Icon::show('refresh fa-spin', ['style' => 'display: none;'], 'fa'), ['class' => 'btn btn-info btn-xs', 'data-package-name' => $data["composer_name"], 'data-action' => 'ext-info']) . $activateButton;
    return sprintf($nameBlockTpl, $name, $description, $buttons, str_replace(['\\', '/'], '', $data["composer_name"]));
}], ['label' => Yii::t('extensions-manager', 'Version'), 'content' => function ($data) use($composerSet) {
    return ExtensionDataHelper::getLocalizedDataField($composerSet->getInstalled($data["composer_name"]), Extension::TYPE_YII, 'version');
}, 'options' => ['width' => '150px']], ['label' => Yii::t('extensions-manager', 'Type'), 'attribute' => 'composer_type', 'content' => function ($data) {
    $types = Extension::getTypes();
    return isset($types[$data['composer_type']]) ? $types[$data['composer_type']] : Yii::t('extensions-manager', 'Undefined extension type');
}, 'options' => ['width' => '150px']], ['label' => Yii::t('extensions-manager', 'Active'), 'attribute' => 'is_active', 'content' => function ($data) {
    return Yii::$app->formatter->asBoolean($data["is_active"]);
}, 'options' => ['width' => '150px']]]]);
?>
        </div>
    </div>
</div>