craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 624 forks source link

Plugins installed via composer lack some "extra" array attributes #1695

Closed khalwat closed 7 years ago

khalwat commented 7 years ago

I switched over from manually installing a local plugin to installing it via composer via path. It all works, except the extra array key is missing. Here's what the craftcms/plugins.php looks like:

<?php

$vendorDir = dirname(__DIR__);

return array (
  'nystudio107/craft3-seomatic' => 
  array (
    'class' => 'nystudio107\\seomatic\\Seomatic',
    'basePath' => $vendorDir . '/nystudio107/craft3-seomatic/src',
    'aliases' => 
    array (
      '@nystudio107/seomatic' => $vendorDir . '/nystudio107/craft3-seomatic/src',
    ),
    'name' => 'SEOmatic',
    'handle' => 'seomatic',
    'version' => '3.0.0-beta.1',
    'schemaVersion' => '3.0.0',
    'description' => 'A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, and flexible',
    'developer' => 'nystudio107',
    'developerUrl' => 'https://nystudio107.com',
    'documentationUrl' => 'https://github.com/nystudio107/craft3-seomatic/blob/master/README.md',
    'components' => 
    array (
      'frontendTemplates' => 'nystudio107\\seomatic\\services\\FrontendTemplates',
      'metaContainers' => 'nystudio107\\seomatic\\services\\MetaContainers',
      'metaBundles' => 'nystudio107\\seomatic\\services\\MetaBundles',
      'sitemaps' => 'nystudio107\\seomatic\\services\\Sitemaps',
      'redirects' => 'nystudio107\\seomatic\\services\\Redirects',
    ),
  ),
);

but here's what the plugin's actual composer.json looks like:

{
    "name": "nystudio107/craft3-seomatic",
    "description": "A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, and flexible",
    "type": "craft-plugin",
    "version": "3.0.0-beta.1",
    "keywords": [
        "craft",
        "cms",
        "craftcms",
        "craft-plugin",
        "seomatic"
    ],
    "support": {
        "docs": "https://github.com/nystudio107/craft3-seomatic/blob/master/README.md",
        "issues": "https://github.com/nystudio107/craft3-seomatic/issues"
    },
    "license": "proprietary",
    "authors": [
        {
          "name": "nystudio107",
          "homepage": "https://nystudio107.com"
        }
    ],
    "require": {
        "craftcms/cms": "~3.0.0-beta.1",
        "craftcms/vue-asset": "^1.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ],
    "autoload": {
        "psr-4": {
          "nystudio107\\seomatic\\": "src/"
        }
    },
    "extra": {
        "name": "SEOmatic",
        "handle": "seomatic",
        "schemaVersion": "3.0.0",
        "hasCpSettings": true,
        "hasCpSection": true,
        "changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft3-seomatic/master/CHANGELOG.md",
        "class": "nystudio107\\seomatic\\Seomatic",
        "components": {
            "frontendTemplates": "nystudio107\\seomatic\\services\\FrontendTemplates",
            "metaContainers": "nystudio107\\seomatic\\services\\MetaContainers",
            "metaBundles": "nystudio107\\seomatic\\services\\MetaBundles",
            "sitemaps": "nystudio107\\seomatic\\services\\Sitemaps",
            "redirects": "nystudio107\\seomatic\\services\\Redirects"
        }
    }
}

The plugin otherwise works fine, but things like hasCpSettings and hasCpSection from the extra array are not picked up, and therefor not used.

It looks like some of the properties from the extra array are flattened over into the craftcms/plugins.php config, but not all of them.

khalwat commented 7 years ago

Manually adding these key/values to the craftcms/plugins.php does fix it:

    'hasCpSettings' => true,
    'hasCpSection' => true,

It looks like they are just plain missing from the plugin-installer: https://github.com/craftcms/plugin-installer/blob/master/src/Installer.php#L121

khalwat commented 7 years ago

heh, okay, it looks like this was fixed in develop. Closing & pulling.

brandonkelly commented 7 years ago

@khalwat I don't remember us fixing anything related to this recently; where are you seeing the fix?

khalwat commented 7 years ago

It was user-error. I had a very old version of the plugin-installer back from pre-beta days, I needed to manually update it via git pull since I'm still using that setup locally on one of my computers.

brandonkelly commented 7 years ago

Ah ok :)