diff --git a/composer.json b/composer.json index 673679757..656e7f179 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "composer/installers": "^2.0", "cweagans/composer-patches": "^1.7", "drupal/bartik": "^1.0", + "drupal/panelizer": "^4.5", "egulias/email-validator": "4.0.1 as 3.2.6", "govcms/govcms": "3.x-develop-dev", "govcms/govcms-custom": "*", diff --git a/modules/distro/panelizer/.codeclimate.yml b/modules/distro/panelizer/.codeclimate.yml deleted file mode 100644 index e8b0bd077..000000000 --- a/modules/distro/panelizer/.codeclimate.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -engines: - csslint: - enabled: true - duplication: - enabled: true - config: - languages: - - javascript - - php - eslint: - enabled: true - fixme: - enabled: true - phpmd: - enabled: true -ratings: - paths: - - "**.css" - - "**.inc" - - "**.install" - - "**.js" - - "**.module" - - "**.php" - - "**.test" diff --git a/modules/distro/panelizer/.csslintrc b/modules/distro/panelizer/.csslintrc deleted file mode 100644 index aacba956e..000000000 --- a/modules/distro/panelizer/.csslintrc +++ /dev/null @@ -1,2 +0,0 @@ ---exclude-exts=.min.css ---ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes diff --git a/modules/distro/panelizer/.eslintignore b/modules/distro/panelizer/.eslintignore deleted file mode 100644 index 96212a359..000000000 --- a/modules/distro/panelizer/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/*{.,-}min.js diff --git a/modules/distro/panelizer/.eslintrc b/modules/distro/panelizer/.eslintrc deleted file mode 100644 index 9faa37508..000000000 --- a/modules/distro/panelizer/.eslintrc +++ /dev/null @@ -1,213 +0,0 @@ -ecmaFeatures: - modules: true - jsx: true - -env: - amd: true - browser: true - es6: true - jquery: true - node: true - -# http://eslint.org/docs/rules/ -rules: - # Possible Errors - comma-dangle: [2, never] - no-cond-assign: 2 - no-console: 0 - no-constant-condition: 2 - no-control-regex: 2 - no-debugger: 2 - no-dupe-args: 2 - no-dupe-keys: 2 - no-duplicate-case: 2 - no-empty: 2 - no-empty-character-class: 2 - no-ex-assign: 2 - no-extra-boolean-cast: 2 - no-extra-parens: 0 - no-extra-semi: 2 - no-func-assign: 2 - no-inner-declarations: [2, functions] - no-invalid-regexp: 2 - no-irregular-whitespace: 2 - no-negated-in-lhs: 2 - no-obj-calls: 2 - no-regex-spaces: 2 - no-sparse-arrays: 2 - no-unexpected-multiline: 2 - no-unreachable: 2 - use-isnan: 2 - valid-jsdoc: 0 - valid-typeof: 2 - - # Best Practices - accessor-pairs: 2 - block-scoped-var: 0 - complexity: [2, 6] - consistent-return: 0 - curly: 0 - default-case: 0 - dot-location: 0 - dot-notation: 0 - eqeqeq: 2 - guard-for-in: 2 - no-alert: 2 - no-caller: 2 - no-case-declarations: 2 - no-div-regex: 2 - no-else-return: 0 - no-empty-label: 2 - no-empty-pattern: 2 - no-eq-null: 2 - no-eval: 2 - no-extend-native: 2 - no-extra-bind: 2 - no-fallthrough: 2 - no-floating-decimal: 0 - no-implicit-coercion: 0 - no-implied-eval: 2 - no-invalid-this: 0 - no-iterator: 2 - no-labels: 0 - no-lone-blocks: 2 - no-loop-func: 2 - no-magic-number: 0 - no-multi-spaces: 0 - no-multi-str: 0 - no-native-reassign: 2 - no-new-func: 2 - no-new-wrappers: 2 - no-new: 2 - no-octal-escape: 2 - no-octal: 2 - no-proto: 2 - no-redeclare: 2 - no-return-assign: 2 - no-script-url: 2 - no-self-compare: 2 - no-sequences: 0 - no-throw-literal: 0 - no-unused-expressions: 2 - no-useless-call: 2 - no-useless-concat: 2 - no-void: 2 - no-warning-comments: 0 - no-with: 2 - radix: 2 - vars-on-top: 0 - wrap-iife: 2 - yoda: 0 - - # Strict - strict: 0 - - # Variables - init-declarations: 0 - no-catch-shadow: 2 - no-delete-var: 2 - no-label-var: 2 - no-shadow-restricted-names: 2 - no-shadow: 0 - no-undef-init: 2 - no-undef: 0 - no-undefined: 0 - no-unused-vars: 0 - no-use-before-define: 0 - - # Node.js and CommonJS - callback-return: 2 - global-require: 2 - handle-callback-err: 2 - no-mixed-requires: 0 - no-new-require: 0 - no-path-concat: 2 - no-process-exit: 2 - no-restricted-modules: 0 - no-sync: 0 - - # Stylistic Issues - array-bracket-spacing: 0 - block-spacing: 0 - brace-style: 0 - camelcase: 0 - comma-spacing: 0 - comma-style: 0 - computed-property-spacing: 0 - consistent-this: 0 - eol-last: 0 - func-names: 0 - func-style: 0 - id-length: 0 - id-match: 0 - indent: 0 - jsx-quotes: 0 - key-spacing: 0 - linebreak-style: 0 - lines-around-comment: 0 - max-depth: 0 - max-len: 0 - max-nested-callbacks: 0 - max-params: 0 - max-statements: [2, 30] - new-cap: 0 - new-parens: 0 - newline-after-var: 0 - no-array-constructor: 0 - no-bitwise: 0 - no-continue: 0 - no-inline-comments: 0 - no-lonely-if: 0 - no-mixed-spaces-and-tabs: 0 - no-multiple-empty-lines: 0 - no-negated-condition: 0 - no-nested-ternary: 0 - no-new-object: 0 - no-plusplus: 0 - no-restricted-syntax: 0 - no-spaced-func: 0 - no-ternary: 0 - no-trailing-spaces: 0 - no-underscore-dangle: 0 - no-unneeded-ternary: 0 - object-curly-spacing: 0 - one-var: 0 - operator-assignment: 0 - operator-linebreak: 0 - padded-blocks: 0 - quote-props: 0 - quotes: 0 - require-jsdoc: 0 - semi-spacing: 0 - semi: 0 - sort-vars: 0 - space-after-keywords: 0 - space-before-blocks: 0 - space-before-function-paren: 0 - space-before-keywords: 0 - space-in-parens: 0 - space-infix-ops: 0 - space-return-throw-case: 0 - space-unary-ops: 0 - spaced-comment: 0 - wrap-regex: 0 - - # ECMAScript 6 - arrow-body-style: 0 - arrow-parens: 0 - arrow-spacing: 0 - constructor-super: 0 - generator-star-spacing: 0 - no-arrow-condition: 0 - no-class-assign: 0 - no-const-assign: 0 - no-dupe-class-members: 0 - no-this-before-super: 0 - no-var: 0 - object-shorthand: 0 - prefer-arrow-callback: 0 - prefer-const: 0 - prefer-reflect: 0 - prefer-spread: 0 - prefer-template: 0 - require-yield: 0 diff --git a/modules/distro/panelizer/CHANGELOG.txt b/modules/distro/panelizer/CHANGELOG.txt deleted file mode 100644 index 8e9ae484b..000000000 --- a/modules/distro/panelizer/CHANGELOG.txt +++ /dev/null @@ -1,120 +0,0 @@ -Panelizer 8.x-4.x-dev, xxxx-xx-xx ---------------------------------- -#2889815 by samuel.mortenson: Fix tests for Panelizer 8.x. -#2889810 by douggreen: Standardize test group as "panelizer". Fix - PanelizerLayoutIDUpdateTest group. -#2908917 by phenaproxima: SaveTabView assumes a Revert tab exists. -#2899910 by DamienMcKenna, anshuljain2k8: Fixed naming convention for info file - dependencies. -#2912622 by gaydabura: Panelizer field should only show enabled view modes. -#2878095 by zuernBernhard: Panelizer Post Update fails in combination with - search_api index tracking. -#3288958 by Project Update Bot, DamienMcKenna: Drupal 10 compatibility fixes. - - -Panelizer 8.x-4.0, 2017-04-28 ------------------------------ -By DamienMcKenna: Identify hook_post_update_NAME(). -#2871157 by tim.plunkett, carstenG, samerali: - panelizer_post_update_rename_layout_machine_names() does not work. -#2677924 by maxneaga: 'Revert to default' needs a confirmation. - - -Panelizer 8.x-4.0-beta3, 2017-04-18 ------------------------------------ -#2867568 by japerry: Update hook to fix layout machine names. -#2866705 by japerry: Add handling for revision support when saving custom - panelizer layouts. -#2856471 by phenaproxima, samuel.mortenson, japerry: IPE on Panelizer nodes - should only allow for custom overrides. -#2867503 by DamienMcKenna, phenaproxima: Change tests to not use the "standard" - installation profile, move PanelizerAddDefaultLinkTest to functional tests. -#2699085 by tim.plunkett: Lock PanelsIPE when a user has made TempStore changes. -#2867819 by DamienMcKenna: Cloned NodeFunctionalTests to focus on translations. -By japerry: Make it clear to the site builder that they can select defaults by - adding the panelizer field. -By DamienMcKenna: Noting some translation todos. -#2870719 by DamienMcKenna: Moved all tests to the 'panelizer' test group. - - -Panelizer 8.x-4.0-beta2, 2017-04-04 ------------------------------------ -By DamienMcKenna: Tidied up the dependencies a little. -By DamienMcKenna: Trying to solve composer dependencies in Panels by - specifically requiring Panels IPE 4.x. -#2858488 by tim.plunkett: Moved PanelizerIntegrationTest from Panels to - Panelizer. -#2866903 by japerry, EclipseGc: Updated composer.json for compatibility with - core 8.3. - - -Panelizer 8.x-4.0-beta1, 2017-03-04 ------------------------------------ -#2856102 by japerry, DamienMcKenna, tim.plunkett, Mixologic: Updated to work - with Panels 8.x-4.x and Drupal core 8.3.x. - - -Panelizer 8.x-3.x-dev, xxxx-xx-xx ---------------------------------- -#2850246 by DamienMcKenna: Added a new permission to control who has access to - the 'reset to default' option, added some tests for IPE functionality. -#2852739 by DamienMcKenna: Added files for controlling the codeclimate testing - system. -#2854655 by DamienMcKenna: Added a custom composer.json file to clearly define - the dependencies. -By DamienMcKenna: Grouped theme functions together in panelizer.module. - - -Panelizer 8.x-3.0-beta1, 2017-02-04 ------------------------------------ -#2828840 by hctom, DamienMcKenna: Handle entity types that use - RevisionableInterface but are not revisionable. -#2664574 by artreaktor, phenaproxima, hctom, jiff, floretan: Add support for - Taxonomy Term entities. -#2835590 by DamienMcKenna: Hide the custom Panelizer field, it's no longer used. -#2800991 by garethhallnz: Allow other modules to change the view_mode being - rendered. -#2847351 by porchlight, rvillan, DamienMcKenna: Permission to 'Set as Default' - in the Panelizer IPE. -#2727629 by samuel.mortenson, Dane Powell, dsnopek: Panelized nodes sporadically - become locked. -#2664572 by hctom, balsama, smurrayatwork, DamienMcKenna: Support for user - entities. -By DamienMcKenna: Does not support comment entities. -#2835587 by DamienMcKenna: Minor UX tweaks, code improvements. - - -Panelizer 8.x-3.0-alpha3, 2016-12-15 ------------------------------------- -#2664648: Added unit tests for PanelizerDefaultPanelsStorage and - PanelizerFieldPanelsStorage. -Reverted #2664616. -#2688951 by swentel, hampercm, wiifm: Panels IPE javascript loaded, even when - you have no access to the in place editor. -#2760051 by Gravypower: Undefined index: #attached. -#2795375 by webflo: Theme suggestions are in the wrong order. -#2820562 by jiff: Node functional test fails due to non-existent permission. -#2716071 by Xano: PanelizerFieldPanelsStorage::access() calls entity access with - incorrect operations and excludes cacheability metadata. -#2693163 by samuel.mortenson: Quick Edit support for fields displayed using the - ctools_field block. -#2700597 by samuel.mortenson, mdooley: Explicitly set the Panels IPE URL root - when saving in Panelizer. -#2664682 by juampynr, EclipseGc, phenaproxima, balsama, japerry, Dane Powell, - samuel.mortenson, hctom: Implement admin UI for editing Panelizer defaults. -#2701349 by EclipseGc: Generate new UUIDs for displays when switching from - default to field storage. - - -Panelizer 8.x-3.0-alpha2, 2016-02-16 ------------------------------------- -- Add basic functional tests. -- Add permission for changing layout. -- "Undefined Index: label in Drupal\panelizer\Panelizer->getPermissions()." -- Contextual blocks not shown in the IPE. -- PanelizerFieldType::generateSampleValue() needs to specify a view mode. - - -Panelizer 8.x-3.0-alpha1, 2016-02-05 ------------------------------------- -Initial D8 port by dsnopek and the Panels contributors. diff --git a/modules/distro/panelizer/LICENSE.txt b/modules/distro/panelizer/LICENSE.txt deleted file mode 100644 index d159169d1..000000000 --- a/modules/distro/panelizer/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/modules/distro/panelizer/README.txt b/modules/distro/panelizer/README.txt deleted file mode 100644 index d00f41d5c..000000000 --- a/modules/distro/panelizer/README.txt +++ /dev/null @@ -1,40 +0,0 @@ -Panelizer ---------- -The Panelizer module allows supported entities to be treated as Panels [1], -giving options for different default displays on a per bundle basis. For -example, this allows each node display to be customized individually. - - -Features --------------------------------------------------------------------------------- -* Supports Drupal core's included entities - nodes, taxonomy terms and users. - -* Can be easily extended to support additional entities. - - -Requirements --------------------------------------------------------------------------------- -CTools v8.x-3.x [2] -Panels v8.x-4.x - -This version is only designed to be compatible with Drupal 8.3.x and above, it -is not compatible with 8.2.x and the Layout Plugin module. - - -Credits / Contact --------------------------------------------------------------------------------- -Drupal 8 port by David Snopek [3] and the Panels contributors. Originally -written by merlinofchaos [4]. Additional maintenance by Damien McKenna [5] - -The best way to contact the authors is to submit an issue, be it a support -request, a feature request or a bug report, in the project's issue queue: - https://www.drupal.org/project/issues/panelizer - - -References --------------------------------------------------------------------------------- -1: https://www.drupal.org/project/panels -2: https://www.drupal.org/project/ctools -3: https://www.drupal.org/u/dsnopek -4: https://www.drupal.org/u/merlinofchaos -5: https://www.drupal.org/u/damienmckenna diff --git a/modules/distro/panelizer/composer.json b/modules/distro/panelizer/composer.json deleted file mode 100644 index 7fd2713d7..000000000 --- a/modules/distro/panelizer/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "drupal/panelizer", - "description": "Allow any entity view mode to be rendered using a Panels display.", - "type": "drupal-module", - "homepage": "https://www.drupal.org/project/panelizer", - "authors": [ - { - "name": "Damien McKenna", - "homepage": "https://www.drupal.org/u/damienmckenna" - }, - { - "name": "Kris Vanderwater", - "homepage": "https://www.drupal.org/u/eclipsegc" - }, - { - "name": "David Snopek", - "homepage": "https://www.drupal.org/u/dsnopek" - }, - { - "name": "Jakob Perry", - "homepage": "https://www.drupal.org/u/japerry" - }, - { - "name": "Earl Miles", - "homepage": "https://www.drupal.org/u/merlinofchaos" - }, - { - "name": "See other contributors", - "homepage":"https://www.drupal.org/node/1072922/committers" - } - ], - "support": { - "issues": "https://www.drupal.org/project/issues/panelizer", - "source": "http://git.drupal.org/project/panelizer.git" - }, - "license": "GPL-2.0-or-later", - "minimum-stability": "dev", - "require": { - "drupal/ctools": "^3.1 || dev-3.x", - "drupal/panels": "^4.4 || dev-4.x", - "drupal/core": "^9 || ^10" - } -} diff --git a/modules/distro/panelizer/config/schema/panelizer.schema.yml b/modules/distro/panelizer/config/schema/panelizer.schema.yml deleted file mode 100644 index 8b873a96e..000000000 --- a/modules/distro/panelizer/config/schema/panelizer.schema.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Config schema for Panelizer. -panelizer.default.display: - type: display_variant.plugin.panels_variant - label: 'Panelizer display default' - mapping: - static_context: - type: ctools.context - label: 'Contexts' - pattern: - type: string - label: 'Pattern plugin ID' - -core.entity_view_display.*.*.*.third_party.panelizer: - type: mapping - mapping: - enable: - type: boolean - description: 'Is Panelizer enabled?' - custom: - type: boolean - description: 'Are custom overrides allowed?' - allow: - type: boolean - description: 'Is choosing between available defaults during entity creation allowed?' - default: - type: string - description: 'Default display ID' - displays: - type: sequence - description: 'Default displays' - sequence: - type: panelizer.default.display - description: 'Default displays' diff --git a/modules/distro/panelizer/css/panelizer.admin.css b/modules/distro/panelizer/css/panelizer.admin.css deleted file mode 100644 index 1aa379464..000000000 --- a/modules/distro/panelizer/css/panelizer.admin.css +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file - * Styles for Panelizer wizard admin. - */ - -/* Narrow screens */ - -.panelizer-wizard-tree, -.panelizer-wizard-form { - box-sizing: border-box; -} - -/** - * Wizard actions across the top. - */ -.panelizer-wizard-actions { - text-align: right; /* LTR */ -} -.panelizer-wizard-actions ul.inline, -.panelizer-wizard-actions ul.inline li { - display: inline-block; - margin: 0; -} -.panelizer-wizard-actions ul.inline { - border-top: 1px solid black; - border-left: 1px solid black; -} -.panelizer-wizard-actions ul.inline li { - border-right: 1px solid black; - padding: .5em; -} - -/** - * The tree of wizard steps. - */ -.panelizer-wizard-tree ul { - margin: 0; - padding: 0; - list-style: none; -} -.panelizer-wizard-tree ul > li > ul { - margin-left: 1em; -} -.panelizer-wizard-tree > ul { - border: 1px solid black; - padding-bottom: .5em; - margin-bottom: 20px; -} -.panelizer-wizard-tree li { - border-bottom: 1px solid black; - padding: .5em; - padding-right: 0; -} -.panelizer-wizard-tree li:last-child { - border-bottom: 0; - padding-bottom: 0; -} - -/** - * The wizard form. - */ -.panelizer-wizard-form { - border: 1px solid black; - padding: 1em; - margin-bottom: 20px; -} - -/* Wide screens */ -@media - screen and (min-width: 780px), - (orientation: landscape) and (min-device-height: 780px) { - - /** - * Overall layout. - */ - .panelizer-wizard-tree { - float: left; /* LTR */ - width: 20%; - } - .panelizer-wizard-form { - float: left; /* LTR */ - width: 80%; - } - .panelizer-wizard-form-actions { - margin-left: 20%; /* LTR */ - } - - /** - * Make the borders look nice. - */ - .panelizer-wizard-tree > ul { - border-right: 0; /* LTR */ - } - .panelizer-wizard-form { - min-height: 400px; - } - - /** - * Right-to-left support. - */ - [dir="rtl"] .panelizer-wizard-tree, - [dir="rtl"] .panelizer-wizard-form { - float: right; - } - [dir="rtl"] .panelizer-wizard-form-actions { - margin-left: 0; - margin-right: 20%; - } - [dir="rtl"] .panelizer-wizard-tree > ul { - border-right: 1px solid black; - border-left: 0; - } -} diff --git a/modules/distro/panelizer/css/panels_ipe.css b/modules/distro/panelizer/css/panels_ipe.css deleted file mode 100644 index c5e26d2c9..000000000 --- a/modules/distro/panelizer/css/panels_ipe.css +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * Stylesheet for Panelizer IPE customizations. - */ - -.panelizer-ipe-save-button { - display: inline-block; - margin: 10px; -} - -.ipe-icon.ipe-icon-revert:before { - /* @todo: Make a new icon for revert! */ - content: "\e90a"; -} - -/* Show the cancel title so it easier to tell the difference from revert. */ -[data-tab-id="cancel"] .ipe-tab-title { - display: inline; -} - diff --git a/modules/distro/panelizer/js/panelizer-default-form.js b/modules/distro/panelizer/js/panelizer-default-form.js deleted file mode 100644 index 76aafe84a..000000000 --- a/modules/distro/panelizer/js/panelizer-default-form.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file - * Javascript for the Panelizer defaults page. - */ -(function ($) { - Drupal.behaviors.panelizer_default_form = { - attach: function (context, settings) { - var $panelizer_checkbox = $(':input[name="panelizer[enable]"]'); - - function update_form() { - var $core_form = $('#field-display-overview-wrapper'); - if ($panelizer_checkbox.is(':checked')) { - $core_form.fadeOut(); - } - else { - $core_form.fadeIn(); - } - } - - $panelizer_checkbox.once('panelizer-default-form').click(update_form); - update_form(); - } - }; -})(jQuery); diff --git a/modules/distro/panelizer/js/panels_ipe/panels_ipe.js b/modules/distro/panelizer/js/panels_ipe/panels_ipe.js deleted file mode 100644 index 36af7740c..000000000 --- a/modules/distro/panelizer/js/panels_ipe/panels_ipe.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file - * Entry point for the Panelizer IPE customizations. - */ - -(function ($, _, Backbone, Drupal) { - - 'use strict'; - - Drupal.panelizer = Drupal.panelizer || {}; - - /** - * @namespace - */ - Drupal.panelizer.panels_ipe = {}; - - /** - * Make customizations to the Panels IPE for Panelizer. - */ - Backbone.on('PanelsIPEInitialized', function() { - // Disable the normal save event. - Drupal.panels_ipe.app_view.stopListening(Drupal.panels_ipe.app.get('saveTab'), 'change:active'); - - // Add a new revert tab model. - if (drupalSettings.panelizer.user_permission.revert) { - var revert_tab = new Drupal.panels_ipe.TabModel({title: 'Revert to default', id: 'revert'}); - Drupal.panels_ipe.app_view.tabsView.collection.add(revert_tab); - - // @todo: Put this into a proper view? - Drupal.panels_ipe.app_view.listenTo(revert_tab, 'change:active', function () { - var entity = drupalSettings.panelizer.entity; - if (revert_tab.get('active') && !revert_tab.get('loading')) { - if (confirm(Drupal.t('Are you sure you want to revert to default layout? All your layout changes will be lost for this node.'))) { - // Remove our changes and refresh the page. - revert_tab.set({loading: true}); - $.ajax({ - url: drupalSettings.path.baseUrl + 'admin/panelizer/panels_ipe/' + entity.entity_type_id + '/' + entity.entity_id + '/' + entity.view_mode + '/revert_to_default', - data: {}, - type: 'POST' - }).done(function (data) { - location.reload(); - }); - } - else { - revert_tab.set('active', false, {silent: true}); - } - } - }); - - // Hide the 'Revert to default' button if we're already on a default. - if (drupalSettings.panels_ipe.panels_display.storage_type == 'panelizer_default') { - revert_tab.set({hidden: true}); - } - } - - // Hide the 'Revert to default' button if the user does not have permission. - // if (!drupalSettings.panelizer.user_permission.revert) { - // revert_tab.set({hidden: true}); - // } - - // Add a new view for the save button to the TabsView. - var tabs = { - model: Drupal.panels_ipe.app_view.model, - tabsView: Drupal.panels_ipe.app_view.tabsView, - }; - if (typeof revert_tab !== 'undefined') { - tabs.revertTab = revert_tab; - } - Drupal.panels_ipe.app_view.tabsView.tabViews['save'] = new Drupal.panelizer.panels_ipe.SaveTabView(tabs); - }); - -}(jQuery, _, Backbone, Drupal)); diff --git a/modules/distro/panelizer/js/panels_ipe/views/SaveTabView.js b/modules/distro/panelizer/js/panels_ipe/views/SaveTabView.js deleted file mode 100644 index 547c8eaf1..000000000 --- a/modules/distro/panelizer/js/panels_ipe/views/SaveTabView.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file - * Contains Drupal.panelizer.panels_ipe.SaveTabView. - */ - -(function ($, _, Backbone, Drupal) { - 'use strict'; - - Drupal.panelizer.panels_ipe.SaveTabView = Backbone.View.extend(/** @lends Drupal.panelizer.panels_ipe.SaveTabView# */{ - - /** - * @type {function} - */ - template: function() { - return ''; - }, - - /** - * @type {Drupal.panels_ipe.AppModel} - */ - model: null, - - /** - * @type {Drupal.panels_ipe.TabsView} - */ - tabsView: null, - - /** - * @type {Drupal.panels_ipe.TabModel} - */ - revertTab: null, - - /** - * @type {object} - */ - events: { - }, - - /** - * @type {function} - */ - onClick: function () { - if (this.model.get('saveTab').get('active')) { - // Always save as a custom override. - this.saveCustom(); - } - }, - - /** - * @type {function} - */ - saveCustom: function () { - this._save('panelizer_field'); - }, - - /** - * @type {function} - */ - _save: function (storage_type) { - var self = this, - layout = this.model.get('layout'); - - // Give the backend enough information to save in the correct way. - layout.set('panelizer_save_as', storage_type); - layout.set('panelizer_entity', drupalSettings.panelizer.entity); - - if (this.model.get('saveTab').get('active')) { - // Save the Layout and disable the tab. - this.model.get('saveTab').set({loading: true, active: false}); - this.tabsView.render(); - layout.save().done(function () { - self.model.get('saveTab').set({loading: false}); - self.model.set('unsaved', false); - - // Change the storage type and id for the next save. - drupalSettings.panels_ipe.panels_display.storage_type = storage_type; - drupalSettings.panels_ipe.panels_display.storage_id = drupalSettings.panelizer.entity[storage_type + '_storage_id']; - Drupal.panels_ipe.setUrlRoot(drupalSettings); - - // Show/hide the revert to default tab. - if (self.revertTab) { - self.revertTab.set({hidden: storage_type === 'panelizer_default'}); - } - self.tabsView.render(); - }); - } - }, - - /** - * @constructs - * - * @augments Backbone.View - * - * @param {Object} options - * An object containing the following keys: - * @param {Drupal.panels_ipe.AppModel} options.model - * The app state model. - * @param {Drupal.panels_ipe.TabsView} options.tabsView - * The app view. - * @param {Drupal.panels_ipe.TabModel} options.revertTab - * The revert tab. - */ - initialize: function (options) { - this.model = options.model; - this.tabsView = options.tabsView; - this.revertTab = options.revertTab; - - this.listenTo(this.model.get('saveTab'), 'change:active', this.onClick); - }, - - /** - * Renders the selection menu for picking Layouts. - * - * @return {Drupal.panelizer.panels_ipe.SaveTabView} - * Return this, for chaining. - */ - render: function () { - this.$el.html(this.template()); - return this; - } - - }); - -}(jQuery, _, Backbone, Drupal)); diff --git a/modules/distro/panelizer/panelizer.api.php b/modules/distro/panelizer/panelizer.api.php deleted file mode 100644 index 1b5b0bb45..000000000 --- a/modules/distro/panelizer/panelizer.api.php +++ /dev/null @@ -1,31 +0,0 @@ -bundle() == 'page') { - $view_mode = 'my_custom_view_mode'; - } -} - -/** - * @} End of "addtogroup hooks". - */ diff --git a/modules/distro/panelizer/panelizer.info.yml b/modules/distro/panelizer/panelizer.info.yml deleted file mode 100644 index f9cf276e4..000000000 --- a/modules/distro/panelizer/panelizer.info.yml +++ /dev/null @@ -1,16 +0,0 @@ -type: module -name: Panelizer [DEPRECATED - DO NOT USE] -description: 'Allow any entity view mode to be rendered using a Panels display.' -package: Layout -core_version_requirement: '^9 || ^10' -dependencies: - - drupal:layout_discovery - - drupal:field_ui - - ctools:ctools_block - - panels:panels - - panels:panels_ipe - -# Information added by Drupal.org packaging script on 2022-08-23 -version: '8.x-4.4+2-dev' -project: 'panelizer' -datestamp: 1661286213 diff --git a/modules/distro/panelizer/panelizer.install b/modules/distro/panelizer/panelizer.install deleted file mode 100644 index ba3925d61..000000000 --- a/modules/distro/panelizer/panelizer.install +++ /dev/null @@ -1,33 +0,0 @@ -listAll('core.entity_view_display.') as $entity_display_name) { - $entity_display = $config_factory->getEditable($entity_display_name); - if ($displays = $entity_display->get('third_party_settings.panelizer.displays')) { - foreach ($displays as $display_name => $display) { - if (isset($display['layout'])) { - $new_layout = panels_convert_plugin_ids_to_layout_discovery($display['layout']); - if ($new_layout) { - $displays[$display_name]['layout'] = $new_layout; - } - } - } - $entity_display - ->set('third_party_settings.panelizer.displays', $displays) - // Mark the resulting configuration as trusted data. This avoids issues - // with future schema changes. - ->save(TRUE); - } - } -} diff --git a/modules/distro/panelizer/panelizer.libraries.yml b/modules/distro/panelizer/panelizer.libraries.yml deleted file mode 100644 index 50b9c7622..000000000 --- a/modules/distro/panelizer/panelizer.libraries.yml +++ /dev/null @@ -1,24 +0,0 @@ -panelizer_default_form: - version: VERSION - js: - js/panelizer-default-form.js: {} - dependencies: - - core/jquery - - core/jquery.once -panels_ipe: - version: VERSION - js: - # Core. - js/panels_ipe/panels_ipe.js: {} - # Views. - js/panels_ipe/views/SaveTabView.js: {} - css: - component: - css/panels_ipe.css: {} - dependencies: - - panels_ipe/panels_ipe -wizard_admin: - version: VERSION - css: - layout: - css/panelizer.admin.css: {} diff --git a/modules/distro/panelizer/panelizer.links.action.yml b/modules/distro/panelizer/panelizer.links.action.yml deleted file mode 100644 index 6ed51fe31..000000000 --- a/modules/distro/panelizer/panelizer.links.action.yml +++ /dev/null @@ -1,5 +0,0 @@ -panelizer.default.add: - route_name: panelizer.wizard.add - title: 'Add a new Panelizer default display' - class: \Drupal\panelizer\Menu\AddDefaultLocalAction - deriver: \Drupal\panelizer\Plugin\AddDefaultLinkDeriver diff --git a/modules/distro/panelizer/panelizer.module b/modules/distro/panelizer/panelizer.module deleted file mode 100644 index badc90dc0..000000000 --- a/modules/distro/panelizer/panelizer.module +++ /dev/null @@ -1,407 +0,0 @@ - [ - 'render element' => 'element', - ], - 'panelizer_wizard_form' => [ - 'render element' => 'form', - ], - 'panelizer_wizard_tree' => [ - 'variables' => [ - 'wizard' => NULL, - 'cached_values' => [], - 'tree' => [], - 'divider' => ' ยป ', - 'step' => NULL, - ], - ], - ]; -} - -/** - * Implements hook_entity_type_alter(). - */ -function panelizer_entity_type_alter(array &$entity_types) { - /** @var \Drupal\panelizer\Plugin\PanelizerEntityManager $panelizer_manager */ - $panelizer_manager = \Drupal::service('plugin.manager.panelizer_entity'); - - // Replace the entity view builder on any entity where we have a Panelizer - // entity plugin and the entity itself has a view builder. - foreach ($panelizer_manager->getDefinitions() as $entity_type_id => $panelizer_info) { - if (isset($entity_types[$entity_type_id]) && $entity_types[$entity_type_id]->hasHandlerClass('view_builder')) { - $entity_types[$entity_type_id]->setHandlerClass('fallback_view_builder', $entity_types[$entity_type_id]->getHandlerClass('view_builder')); - $entity_types[$entity_type_id]->setHandlerClass('view_builder', '\Drupal\panelizer\PanelizerEntityViewBuilder'); - } - } -} - -/** - * Implements hook_panels_build_alter(). - */ -function panelizer_panels_build_alter(&$build, PanelsDisplayVariant $panels_display) { - $builder = $panels_display->getBuilder(); - $storage_type = $panels_display->getStorageType(); - - $is_panelizer = $builder->getPluginId() == 'ipe' && - in_array($storage_type, ['panelizer_default', 'panelizer_field']) && - isset($build['#attached']) && - isset($build['#attached']['library']) && - in_array('panels_ipe/panels_ipe', $build['#attached']['library']); - - // Add our Javascript customizations for the IPE. - if ($is_panelizer) { - $build['#attached']['library'][] = 'panelizer/panels_ipe'; - - /** @var \Drupal\Core\Entity\EntityInterface $entity */ - $entity = $panels_display->getContexts()['@panelizer.entity_context:entity']->getContextValue(); - $revision_id = ($entity instanceof RevisionableInterface && $entity->getEntityType()->isRevisionable()) && !$entity->isDefaultRevision() ? $entity->getRevisionId() : NULL; - list (,, $view_mode) = explode(':', $panels_display->getStorageId()); - - // Get the default storage id, if we're looking at a panelizer default or - // the panelizer field contains a revision. - if (sizeof(explode(':', $panels_display->getStorageId())) == 4) { - list(, , , $default) = explode(':', $panels_display->getStorageId()); - } - else { - $default = NULL; - } - if ($panels_display->getStorageType() == 'panelizer_field') { - $panelizer_default_storage_id = rtrim(implode(':', [$entity->getEntityTypeId(), $entity->bundle(), $view_mode, $default]), ':'); - } - else { - $panelizer_default_storage_id = $panels_display->getStorageId(); - } - - // Get the special, internal default storage id that includes the entity id, - // which will allow us to correctly set the contexts on the Panels display. - $panelizer_default_internal_storage_id = '*' . rtrim(implode(':', [$entity->getEntityTypeId(), $entity->id(), $view_mode, $default]), ':'); - - // Get the custom storage id (omitting revision id if this is the default - // revision). - $panelizer_field_storage_id_parts = [$entity->getEntityTypeId(), $entity->id(), $view_mode]; - if ($revision_id) { - $panelizer_field_storage_id_parts[] = $revision_id; - } - $panelizer_field_storage_id = implode(':', $panelizer_field_storage_id_parts); - - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - - $build['#attached']['drupalSettings']['panelizer']['entity'] = [ - 'entity_type_id' => $entity->getEntityTypeId(), - 'entity_id' => $entity->id(), - 'view_mode' => $view_mode, - 'revision_id' => $revision_id, - 'panelizer_default_storage_id' => $panelizer->hasDefaultPermission('change content', $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $default) ? $panelizer_default_internal_storage_id : FALSE, - 'panelizer_field_storage_id' => $panelizer->hasEntityPermission('change content', $entity, $view_mode) ? $panelizer_field_storage_id : FALSE, - 'panelizer_default_real_storage_id' => $panelizer_default_storage_id, - ]; - - // Whether or not the current user has access to the "revert to default" - // action in the IPE; any user with the 'administer panelizer' will also - // have access. - $build['#attached']['drupalSettings']['panelizer']['user_permission']['revert'] = $panelizer->hasEntityPermission('revert to default', $entity, $view_mode); - - // Whether or not the current user has access to the "set as default" action - // in the IPE; any user with the 'administer panelizer' will also have - // access. - $user = \Drupal::currentUser(); - $build['#attached']['drupalSettings']['panelizer']['user_permission']['save_default'] = $user->hasPermission('set panelizer default') || $user->hasPermission('administer panelizer'); - - if ($panels_display->getStorageType() == 'panelizer_field') { - // If using panelizer_field, we change the storage id to match what we put - // together here because it'll have the revision id omitted in the right - // situation. - $build['#attached']['drupalSettings']['panels_ipe']['panels_display']['storage_id'] = $panelizer_field_storage_id; - } - else { - // If using panelizer_default, we need to switch to a the special, - // internal storage id. - $build['#attached']['drupalSettings']['panels_ipe']['panels_display']['storage_id'] = $panelizer_default_internal_storage_id; - } - } -} - -/** - * Implements hook_panels_ipe_panels_display_presave(). - */ -function panelizer_panels_ipe_panels_display_presave(PanelsDisplayVariant $panels_display, array $layout_model) { - if (empty($layout_model['panelizer_save_as'])) { - return; - } - - // See if the user requested changing the storage type. - $current_storage = $panels_display->getStorageType(); - $panelizer_save_as = $layout_model['panelizer_save_as']; - if ($current_storage !== $panelizer_save_as) { - $panelizer_entity = $layout_model['panelizer_entity']; - - // When actually saving, we want to use the real storage id for me the - // Panelizer default. - $panelizer_entity['panelizer_default_storage_id'] = $panelizer_entity['panelizer_default_real_storage_id']; - - // If we were custom and now we want to save to the default, we need to - // save specially to the Panelizer field so that we can tell it we're on - // a default. - if ($panelizer_save_as == 'panelizer_default') { - /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */ - $entity_type_manager = \Drupal::service("entity_type.manager"); - $storage = $entity_type_manager->getStorage($panelizer_entity['entity_type_id']); - $entity = $storage->load($panelizer_entity['entity_id']); - if ($entity instanceof FieldableEntityInterface) { - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - list (,,, $default_name) = explode(':', $panelizer_entity['panelizer_default_storage_id']); - $panelizer->setPanelsDisplay($entity, $panelizer_entity['view_mode'], $default_name); - } - } - - // We need to generate a new UUID if we're creating a custom display. - if ($current_storage == 'panelizer_default' && $panelizer_save_as == 'panelizer_field') { - $configuration = $panels_display->getConfiguration(); - $configuration['uuid'] = \Drupal::service('uuid')->generate(); - $panels_display->setConfiguration($configuration); - } - - // Set the new storage information. - $panels_display->setStorage($panelizer_save_as, $panelizer_entity[$panelizer_save_as . '_storage_id']); - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - */ -function panelizer_form_entity_view_display_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { - /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ - $form_object = $form_state->getFormObject(); - /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ - $display = $form_object->getEntity(); - - /** @var \Drupal\panelizer\Plugin\PanelizerEntityManager $panelizer_manager */ - $panelizer_manager = \Drupal::service('plugin.manager.panelizer_entity'); - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - - $entity_type_id = $display->getTargetEntityTypeId(); - $bundle = $display->getTargetBundle(); - $mode = $display->getMode(); - - if ($panelizer_manager->hasDefinition($entity_type_id)) { - $settings = $panelizer->getPanelizerSettings($entity_type_id, $bundle, $mode, $display); - - // Always put the field table below the Panelizer options. - $form['fields']['#weight'] = 10; - - $form['panelizer'] = [ - '#tree' => TRUE, - ]; - $form['panelizer']['enable'] = [ - '#type' => 'checkbox', - '#title' => t('Panelize this view mode'), - '#default_value' => isset($settings['enable']) ? $settings['enable'] : FALSE, - ]; - - $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); - - $form['panelizer']['options'] = [ - '#type' => 'details', - '#open' => TRUE, - '#title' => t('Panelizer options'), - '#states' => [ - 'visible' => [ - '#edit-panelizer-enable' => ['checked' => TRUE], - ], - ], - '#parents' => ['panelizer'], - ]; - - $form['panelizer']['options']['custom'] = [ - '#type' => 'checkbox', - '#title' => t('Allow each @entity to have its display customized', [ - '@entity' => $entity_type->getSingularLabel(), - ]), - '#default_value' => isset($settings['custom']) ? $settings['custom'] : FALSE, - ]; - $form['panelizer']['options']['allow'] = [ - '#type' => 'checkbox', - '#title' => t('Allow users to select which display to use'), - '#description' => t('When multiple default displays are available for a view mode it can be useful to allow content creators to choose which display to use for an individual @entity.', [ - '@entity' => $entity_type->getSingularLabel(), - ]) . '
' . t('To enable the choice to be enabled by users, make sure the panelizer field is visible in the Manage form display'), - '#default_value' => isset($settings['allow']) ? $settings['allow'] : FALSE, - ]; - - // If this display mode is panelized, then show the available displays in a - // table. - if (!empty($settings['enable'])) { - $form['#cache']['tags'][] = "panelizer_default:$entity_type_id:$bundle:$mode"; - $form['panelizer']['displays'] = [ - '#type' => 'table', - '#caption' => t('Default displays available for this view mode'), - '#header' => [t('Name'), t('Use as default'), t('Operations')], - ]; - foreach ($display->getThirdPartySetting('panelizer', 'displays', []) as $machine_name => $panels_display) { - // Reset operations when in the foreach loop. - $operations = []; - $display_name = $machine_name; - $machine_name ="{$entity_type_id}__{$bundle}__{$mode}__$machine_name"; - $operations['edit'] = [ - 'title' => t('Edit'), - 'url' => Url::fromRoute('panelizer.wizard.edit', ['machine_name' => $machine_name]), - ]; - if ($settings['default'] != $display_name) { - $operations['set_default'] = [ - 'title' => t('Use as default'), - 'url' => Url::fromRoute('panelizer.default.select', ['machine_name' => $machine_name]), - ]; - $operations['delete'] = [ - 'title' => t('Delete'), - 'url' => Url::fromRoute('panelizer.default.delete', ['machine_name' => $machine_name]), - ]; - } - $form['panelizer']['displays'][$machine_name] = [ - 'label' => ['#markup' => $panels_display['label']], - 'default' => ['#markup' => $settings['default'] == $display_name ? '✓' : ''], - 'operations' => [ - 'data' => [ - '#type' => 'operations', - '#links' => $operations, - ] - ] - ]; - } - $form['fields']['#access'] = FALSE; - } - - $form['#attached']['library'][] = 'panelizer/panelizer_default_form'; - $form['actions']['submit']['#submit'][] = 'panelizer_form_entity_view_display_edit_submit'; - } -} - -function panelizer_form_entity_view_display_edit_submit(&$form, FormStateInterface $form_state) { - $rebuild = FALSE; - /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */ - $form_object = $form_state->getFormObject(); - /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */ - $display = $form_object->getEntity(); - /** @var \Drupal\panelizer\Plugin\PanelizerEntityManager $panelizer_manager */ - $panelizer_manager = \Drupal::service('plugin.manager.panelizer_entity'); - /** @var \Drupal\panelizer\Panelizer $panelizer */ - $panelizer = \Drupal::service('panelizer'); - - if ($panelizer_manager->hasDefinition($display->getTargetEntityTypeId())) { - $settings = $panelizer->getPanelizerSettings($display->getTargetEntityTypeId(), $display->getTargetBundle(), $display->getMode(), $display); - if ($settings['enable'] != $form_state->getValue(['panelizer', 'enable'])) { - $rebuild = TRUE; - } - $settings['enable'] = $form_state->getValue(['panelizer', 'enable']); - $settings['custom'] = $form_state->getValue(['panelizer', 'custom']); - $settings['allow'] = $form_state->getValue(['panelizer', 'allow']); - $panelizer->setPanelizerSettings($display->getTargetEntityTypeId(), $display->getTargetBundle(), $display->getMode(), $settings, $display); - if ($rebuild) { - \Drupal::service('router.builder')->rebuild(); - /** @var \Drupal\Core\Menu\LocalActionManager $local_action_manager */ - $local_action_manager = \Drupal::service('plugin.manager.menu.local_action'); - $local_action_manager->clearCachedDefinitions(); - // Manually reinitialize these. - $local_action_manager->getDefinitions(); - \Drupal::service('cache.render')->invalidateAll(); - } - } -} - -/** - * Implements hook_form_FORM_ID_alter() for field_ui_field_storage_add_form(). - */ -function panelizer_form_field_ui_field_storage_add_form_alter(&$form, FormStateInterface $form_state, $form_id) { - // Hide the legacy Panelizer field. - // @todo Remove the Panelizer field entirely. - if (isset($form['add']['new_storage_type']['#options']['General']['panelizer'])) { - unset($form['add']['new_storage_type']['#options']['General']['panelizer']); - } -} - -/** - * Preprocess function for panelizer-wizard-tree.html.twig. - */ -function template_preprocess_panelizer_wizard_tree(&$variables) { - /** @var $wizard \Drupal\ctools\Wizard\FormWizardInterface|\Drupal\ctools\Wizard\EntityFormWizardInterface */ - $wizard = $variables['wizard']; - $cached_values = $variables['cached_values']; - $tree = $variables['tree']; - $variables['step'] = $wizard->getStep($cached_values); - - foreach ($wizard->getOperations($cached_values) as $step => $operation) { - $parameters = $wizard->getNextParameters($cached_values); - // Override step to be the step we want. - $parameters['step'] = $step; - - // Fill in parents if there are breadcrumbs. - $parent =& $tree; - if (isset($operation['breadcrumbs'])) { - foreach ($operation['breadcrumbs'] as $breadcrumb) { - $breadcrumb_string = (string) $breadcrumb; - if (!isset($parent[$breadcrumb_string])) { - $parent[$breadcrumb_string] = [ - 'title' => $breadcrumb, - 'children' => [], - ]; - } - $parent =& $parent[$breadcrumb_string]['children']; - } - } - - $parent[$step] = [ - 'title' => !empty($operation['title']) ? $operation['title'] : '', - 'url' => new Url($wizard->getRouteName(), $parameters), - 'step' => $step, - ]; - } - - $variables['tree'] = $tree; -} - -/** - * Preprocess function for panelizer-view-mode.html.twig - * - * Prepare variables for Panelizer view mode templates. - */ -function template_preprocess_panelizer_view_mode(&$variables) { - $element = $variables['element']; - - // Copy values into the variables. - /** @var \Drupal\panelizer\Plugin\PanelizerEntityInterface $panelizer_plugin */ - $panelizer_plugin = $variables['panelizer_plugin'] = $element['#panelizer_plugin']; - /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display */ - $panels_display = $variables['panels_display'] = $element['#panels_display']; - /** @var \Drupal\Core\Entity\EntityInterface $entity */ - $entity = $variables['entity'] = $element['#entity']; - $view_mode = $variables['view_mode'] = $element['#view_mode']; - $variables['content'] = $element['content']; - $variables['title'] = isset($element['#title']) ? $element['#title'] : ''; - - // Setup the defaults. - $variables['title_element'] = 'h2'; - $variables['entity_url'] = $entity->toUrl('canonical', [ - 'language' => $entity->language(), - ]); - - // Allow the Panelizer entity plugin to do additional preprocessing. - $panelizer_plugin->preprocessViewMode($variables, $entity, $panels_display, $view_mode); -} - diff --git a/modules/distro/panelizer/panelizer.permissions.yml b/modules/distro/panelizer/panelizer.permissions.yml deleted file mode 100644 index 1fa7b0b0d..000000000 --- a/modules/distro/panelizer/panelizer.permissions.yml +++ /dev/null @@ -1,8 +0,0 @@ -administer panelizer: - title: 'Administer Panelizer' - description: 'Fully administer Panelizer and all Panelizer settings.' -set panelizer default: - title: 'Set Panelizer Default' - description: 'Allow user to "Set as default" in the Panelizer IPE.' -permission_callbacks: - - panelizer:getPermissions diff --git a/modules/distro/panelizer/panelizer.post_update.php b/modules/distro/panelizer/panelizer.post_update.php deleted file mode 100644 index fcb8e184e..000000000 --- a/modules/distro/panelizer/panelizer.post_update.php +++ /dev/null @@ -1,84 +0,0 @@ -getDefinitions() as $entity_type => $definition) { - if (\Drupal::database()->schema()->tableExists($entity_type . '__panelizer')) { - $storage = \Drupal::entityTypeManager()->getStorage($entity_type); - $ids = $storage->getQuery() - ->condition('panelizer', serialize([]), '<>') - ->execute(); - - foreach ($storage->loadMultiple($ids) as $entity_id => $entity) { - $results[] = $entity; - } - } - } - - // Use the sandbox to store the information needed to track progression. - if (!isset($sandbox['current'])) { - // The count of entities visited so far. - $sandbox['current'] = 0; - // Total entities that must be visited. - $sandbox['max'] = count($results); - // A place to store messages during the run. - } - - // Process entities by groups of 20. - // When a group is processed, the batch update engine determines whether it - // should continue processing in the same request or provide progress - // feedback to the user and wait for the next request. - $limit = 5; - $result = array_slice($results, $sandbox['current'], $limit); - - foreach ($result as $entity) { - if ($entity->hasField('panelizer') && $entity->panelizer->first()) { - foreach ($entity->panelizer as $item) { - $panels_display_config = $item->get('panels_display')->getValue(); - - // If our field has custom panelizer display config data. - if (!empty($panels_display_config) && is_array($panels_display_config)) { - $layout_id = $panels_display_config['layout']; - if ($new_layout_id = panels_convert_plugin_ids_to_layout_discovery($layout_id)) { - $panels_display_config['layout'] = $new_layout_id; - $item->set('panels_display', $panels_display_config); - } - } - } - $entity->search_api_skip_tracking = TRUE; - $entity->save(); - } - // Update our progress information. - $sandbox['current']++; - } - - $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); - - if ($sandbox['#finished'] >= 1) { - return t('Panelized custom layouts have been updated.'); - } -} diff --git a/modules/distro/panelizer/panelizer.routing.yml b/modules/distro/panelizer/panelizer.routing.yml deleted file mode 100644 index 5baf178d5..000000000 --- a/modules/distro/panelizer/panelizer.routing.yml +++ /dev/null @@ -1,89 +0,0 @@ -# Panels IPE -panelizer.panels_ipe.revert_to_default: - path: '/admin/panelizer/panels_ipe/{entity_type_id}/{entity}/{view_mode}/revert_to_default' - options: - parameters: - entity: - type: entity:{entity_type_id} - defaults: - _controller: '\Drupal\panelizer\Controller\PanelizerPanelsIPEController::revertToDefault' - requirements: - _method: 'POST' - _permission: 'access panels in-place editing' - _custom_access: '\Drupal\panelizer\Controller\PanelizerPanelsIPEController::accessRevertToDefault' - -# Wizard -panelizer.wizard.add: - path: '/admin/structure/panelizer/add/{entity_type_id}/{bundle}/{view_mode_name}' - defaults: - _wizard: '\Drupal\panelizer\Wizard\PanelizerAddWizard' - _title: 'Panelizer Wizard' - tempstore_id: 'panelizer.wizard' - requirements: - _panelizer_default_access: 'TRUE' - _permission: 'administer panelizer' - -panelizer.wizard.add.step: - path: '/admin/structure/panelizer/add/{machine_name}/{step}' - defaults: - _wizard: '\Drupal\panelizer\Wizard\PanelizerAddWizard' - _title: 'Panelizer Wizard' - tempstore_id: 'panelizer.wizard' - requirements: - _permission: 'administer panelizer' - -panelizer.wizard.edit: - path: '/admin/structure/panelizer/edit/{machine_name}/{step}' - defaults: - _wizard: '\Drupal\panelizer\Wizard\PanelizerEditWizard' - _title: 'Panelizer Wizard' - tempstore_id: 'panelizer.wizard' - step: 'general' - requirements: - _permission: 'administer panelizer' - -panelizer.default.delete: - path: '/admin/structure/panelizer/delete/{machine_name}' - defaults: - _form: '\Drupal\panelizer\Form\PanelizerDefaultDelete' - _title: 'Delete panelizer default' - requirements: - _panelizer_field_ui_view_mode_access: 'TRUE' - _custom_access: '\Drupal\panelizer\Access\PanelizerDefaultsDisplayAccess::isNotDefaultDisplay' - -panelizer.default.select: - path: '/admin/structure/panelizer/set_default/{machine_name}' - defaults: - _form: '\Drupal\panelizer\Form\PanelizerDefaultSelect' - _title: 'Set as default' - requirements: - _panelizer_field_ui_view_mode_access: 'TRUE' - _custom_access: '\Drupal\panelizer\Access\PanelizerDefaultsDisplayAccess::isNotDefaultDisplay' - -# Contexts -panelizer.wizard.step.context.add: - path: '/admin/panelizer/wizard/{machine_name}/contexts/add/{context_id}' - defaults: - _form: '\Drupal\panelizer\Form\PanelizerWizardContextConfigure' - _title: 'Add custom context' - tempstore_id: 'panelizer.wizard' - requirements: - _permission: 'administer panelizer' - -panelizer.wizard.step.context.edit: - path: '/admin/panelizer/wizard/{machine_name}/contexts/edit/{context_id}' - defaults: - _form: '\Drupal\panelizer\Form\PanelizerWizardContextConfigure' - _title: 'Edit context' - tempstore_id: 'panelizer.wizard' - requirements: - _permission: 'administer panelizer' - -panelizer.wizard.step.context.delete: - path: '/admin/panelizer/wizard/{machine_name}/context/delete/{context_id}' - defaults: - _form: '\Drupal\panelizer\Form\PanelizerWizardContextDeleteForm' - _title: 'Delete static context' - tempstore_id: 'panelizer.wizard' - requirements: - _permission: 'administer panelizer' diff --git a/modules/distro/panelizer/panelizer.services.yml b/modules/distro/panelizer/panelizer.services.yml deleted file mode 100644 index d36b86ca5..000000000 --- a/modules/distro/panelizer/panelizer.services.yml +++ /dev/null @@ -1,17 +0,0 @@ -services: - access_check.panelizer.view_mode: - class: Drupal\panelizer\Access\ViewModeAccessCheck - arguments: ['@access_check.field_ui.view_mode'] - tags: - - { name: access_check, applies_to: _panelizer_field_ui_view_mode_access } - plugin.manager.panelizer_entity: - class: Drupal\panelizer\Plugin\PanelizerEntityManager - parent: default_plugin_manager - panelizer: - class: Drupal\panelizer\Panelizer - arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_field.manager', '@plugin.manager.field.field_type', '@module_handler', '@current_user', '@plugin.manager.panelizer_entity', '@panels.display_manager', '@string_translation', '@ctools.context_mapper'] - panelizer.default.access: - class: Drupal\panelizer\Access\DefaultAccess - arguments: ['@panelizer'] - tags: - - { name: access_check, applies_to: _panelizer_default_access } diff --git a/modules/distro/panelizer/panelizer_quickedit/README.txt b/modules/distro/panelizer/panelizer_quickedit/README.txt deleted file mode 100644 index 284bb6837..000000000 --- a/modules/distro/panelizer/panelizer_quickedit/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -Panelizer Quick Edit ---------- -This module contains customizations which allow Panelized Entities to be edited -inline with Quick Edit. It is separate from the Panelizer project as not all -users need this functionality. diff --git a/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.info.yml b/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.info.yml deleted file mode 100644 index 1be832157..000000000 --- a/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.info.yml +++ /dev/null @@ -1,14 +0,0 @@ -type: module -name: Panelizer Quick Edit -description: 'Enables Quick Edit to function normally when using Panelizer.' -package: Layout -# version: VERSION -core_version_requirement: '^9 || ^10' -dependencies: - - panelizer:panelizer - - drupal:quickedit - -# Information added by Drupal.org packaging script on 2022-08-23 -version: '8.x-4.4+2-dev' -project: 'panelizer' -datestamp: 1661286213 diff --git a/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.module b/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.module deleted file mode 100644 index 44c19f071..000000000 --- a/modules/distro/panelizer/panelizer_quickedit/panelizer_quickedit.module +++ /dev/null @@ -1,59 +0,0 @@ -getTranslationFromContext($entity, $langcode); - - // Grab the information required to re-render the entity_field block. - $temp = str_replace('panelizer-', '', $view_mode_id); - list($view_mode, $block_id) = explode('-block-id-', $temp); - - // Load the Panelizer display. - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - $display = $panelizer->getPanelsDisplay($entity, $view_mode); - - /** @var \Drupal\ctools_block\Plugin\Block\EntityField $plugin */ - $plugin = $display->getBlock($block_id); - - // Set the appropriate Entity context and build the plugin. - $plugin->setContextValue('entity', $entity); - $build = $plugin->build(); - - // Add our custom field view-mode in case the user wants to edit again. - $build['field']['#view_mode'] = $view_mode_id; - - return $build; -} - -/** - * Implements hook_entity_view_alter(). - */ -function panelizer_quickedit_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) { - // Explicitly add support for ctools_block by attaching a custom view-mode to - // every Block that's about to be rendered. - if (isset($build['#panels_display'])) { - // We only support known Display Builders. - $supported_plugins = ['ipe', 'standard']; - if (in_array($build['#panels_display']->getBuilder()->getPluginId(), $supported_plugins)) { - $region_names = Element::getVisibleChildren($build['content']); - foreach ($region_names as $region_name) { - $block_ids = Element::getVisibleChildren($build['content'][$region_name]); - foreach ($block_ids as $block_id) { - $block = &$build['content'][$region_name][$block_id]; - if (isset($block['#base_plugin_id']) && $block['#base_plugin_id'] === 'entity_field') { - $view_mode = 'panelizer-' . $build['#view_mode'] . '-block-id-' . $block_id; - $block['content']['field']['#view_mode'] = $view_mode; - } - } - } - } - } -} diff --git a/modules/distro/panelizer/panelizer_quickedit/tests/src/FunctionalJavascript/PanelizerQuickEditTest.php b/modules/distro/panelizer/panelizer_quickedit/tests/src/FunctionalJavascript/PanelizerQuickEditTest.php deleted file mode 100644 index d9f72ba3c..000000000 --- a/modules/distro/panelizer/panelizer_quickedit/tests/src/FunctionalJavascript/PanelizerQuickEditTest.php +++ /dev/null @@ -1,163 +0,0 @@ -drupalCreateContentType(['type' => 'page', 'name' => 'Page']); - - // Add a plain text field for this content type. - FieldStorageConfig::create([ - 'field_name' => 'test_field', - 'entity_type' => 'node', - 'type' => 'string', - ])->save(); - - FieldConfig::create([ - 'field_name' => 'test_field', - 'label' => 'Test Field', - 'entity_type' => 'node', - 'bundle' => 'page', - 'required' => FALSE, - 'settings' => [], - 'description' => '', - ])->save(); - - /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $entity_form_display */ - $entity_form_display = \Drupal::entityTypeManager() - ->getStorage('entity_form_display') - ->load('node.page.default'); - $entity_form_display->setComponent('test_field')->save(); - - /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $entity_display */ - $entity_display = \Drupal::entityTypeManager() - ->getStorage('entity_view_display') - ->load('node.page.default'); - $entity_display->setComponent('test_field')->save(); - - // Create a privileged user. - $user = $this->drupalCreateUser([ - 'access contextual links', - 'access in-place editing', - 'access content', - 'administer node display', - 'administer panelizer', - 'create page content', - 'edit any page content', - ]); - $this->drupalLogin($user); - - // Enable Panelizer for Articles. - $this->drupalGet('admin/structure/types/manage/page/display'); - $this->container->get('panelizer') - ->setPanelizerSettings('node', 'page', 'default', [ - 'enable' => TRUE, - 'allow' => FALSE, - 'custom' => FALSE, - 'default' => 'default', - ]); - } - - /** - * Tests Quick Editing a Panelized Node. - */ - public function testPanelizerQuickEdit() { - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - $displays = $panelizer->getDefaultPanelsDisplays('node', 'page', 'default'); - $display = $displays['default']; - - // Find the "test_field" block. - $block_id = FALSE; - foreach ($display->getConfiguration()['blocks'] as $block) { - if ($block['id'] === 'entity_field:node:test_field') { - $block_id = $block['uuid']; - } - } - - // Make sure we found a valid UUID. - $this->assertNotFalse($block_id); - - // Create an Article. - $node = $this->drupalCreateNode([ - 'type' => 'page', - 'test_field' => [ - 'value' => 'Change me', - ], - ]); - - // Visit the new node. - $this->drupalGet($node->toUrl()); - - // This is the unique ID we append to normal Quick Edit field IDs. - $panelizer_id = 'panelizer-full-block-id-' . $block_id; - - // Assemble common CSS selectors. - $entity_selector = '[data-quickedit-entity-id="node/' . $node->id() . '"]'; - $field_selector = '[data-quickedit-field-id="node/' . $node->id() . '/test_field/' . $node->language()->getId() . '/' . $panelizer_id . '"]'; - - // Wait until Quick Edit loads. - $condition = "jQuery('" . $entity_selector . " .quickedit').length > 0"; - $this->assertJsCondition($condition, 10000); - - // Initiate Quick Editing. - $this->triggerClick($entity_selector . ' [data-contextual-id] > button'); - $this->click($entity_selector . ' [data-contextual-id] .quickedit > a'); - $this->triggerClick($field_selector); - $this->assertSession()->assertWaitOnAjaxRequest(); - - // Trigger an edit with Javascript (this is a "contenteditable" element). - $this->getSession()->executeScript("jQuery('" . $field_selector . "').text('Hello world').trigger('keyup');"); - - // To prevent 403s on save, we re-set our request (cookie) state. - $this->prepareRequest(); - - // Save the change. - $this->triggerClick('.quickedit-button.action-save'); - $this->assertSession()->assertWaitOnAjaxRequest(); - - // Re-visit the node to make sure the edit worked. - $this->drupalGet($node->toUrl()); - $this->assertSession()->pageTextContains('Hello world'); - } - - /** - * Clicks the element with the given CSS selector using event triggers. - * - * @todo Remove when https://github.com/jcalderonzumba/gastonjs/issues/19 - * is fixed. Currently clicking anchors/buttons with nested elements is not - * possible. - * - * @param string $css_selector - * The CSS selector identifying the element to click. - */ - protected function triggerClick($css_selector) { - $this->getSession()->executeScript("jQuery('" . $css_selector . "')[0].click()"); - } - -} diff --git a/modules/distro/panelizer/src/Access/DefaultAccess.php b/modules/distro/panelizer/src/Access/DefaultAccess.php deleted file mode 100644 index 45af31170..000000000 --- a/modules/distro/panelizer/src/Access/DefaultAccess.php +++ /dev/null @@ -1,48 +0,0 @@ -panelizer = $panelizer; - } - - /** - * Determines access to a default Panelizer layout. - * - * @param string $entity_type_id - * The panelized entity type ID. - * @param string $bundle - * The panelized bundle ID. - * @param string $view_mode_name - * The panelized view mode ID. - * - * @return \Drupal\Core\Access\AccessResult - */ - public function access($entity_type_id, $bundle, $view_mode_name) { - $settings = $this->panelizer->getPanelizerSettings($entity_type_id, $bundle, $view_mode_name); - return $settings['enable'] ? AccessResult::allowed() : AccessResult::forbidden(); - } - -} diff --git a/modules/distro/panelizer/src/Access/PanelizerDefaultsDisplayAccess.php b/modules/distro/panelizer/src/Access/PanelizerDefaultsDisplayAccess.php deleted file mode 100644 index 1e76a9bed..000000000 --- a/modules/distro/panelizer/src/Access/PanelizerDefaultsDisplayAccess.php +++ /dev/null @@ -1,34 +0,0 @@ -getPanelizerSettings($entity_type, $bundle, $view_mode); - if ($settings['default'] != $default) { - $access = AccessResult::allowed(); - } - else { - $access = AccessResult::forbidden(); - } - return $access->addCacheTags(["panelizer_default:$entity_type:$bundle:$view_mode", "panelizer_default:$entity_type:$bundle:$view_mode:$default"]); - } - -} diff --git a/modules/distro/panelizer/src/Access/PanelizerUIAccess.php b/modules/distro/panelizer/src/Access/PanelizerUIAccess.php deleted file mode 100644 index a58bdec07..000000000 --- a/modules/distro/panelizer/src/Access/PanelizerUIAccess.php +++ /dev/null @@ -1,18 +0,0 @@ -hasPermission('administer panelizer') ? AccessResult::allowed() : AccessResult::forbidden(); - } - -} diff --git a/modules/distro/panelizer/src/Access/ViewModeAccessCheck.php b/modules/distro/panelizer/src/Access/ViewModeAccessCheck.php deleted file mode 100644 index bb2811098..000000000 --- a/modules/distro/panelizer/src/Access/ViewModeAccessCheck.php +++ /dev/null @@ -1,61 +0,0 @@ -accessCheck = $access_check; - } - - /** - * Adapt the panelizer defaults access check to correspond to field ui. - * - * @param \Symfony\Component\Routing\Route $route - * The original route definition. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The route matched. - * @param \Drupal\Core\Session\AccountInterface $account - * The current user's account. - * @param string $machine_name - * The machine name of the panelizer default. - * - * @return \Drupal\Core\Access\AccessResultInterface - * @throws \Exception - */ - public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $machine_name) { - $parts = explode('__', $machine_name); - if (count($parts) != 4) { - throw new \Exception('The provided machine_name is not well formed.'); - } - list($entity_type_id, $bundle, $view_mode) = $parts; - $defaults = [ - 'entity_type_id' => $entity_type_id, - ] + $route->getDefaults(); - $route->setDefaults($defaults); - $route->setRequirement('_field_ui_view_mode_access', 'administer ' . $entity_type_id . ' display'); - return $this->accessCheck->access($route, $route_match, $account, $view_mode, $bundle); - } - -} diff --git a/modules/distro/panelizer/src/Annotation/PanelizerEntity.php b/modules/distro/panelizer/src/Annotation/PanelizerEntity.php deleted file mode 100644 index 145214389..000000000 --- a/modules/distro/panelizer/src/Annotation/PanelizerEntity.php +++ /dev/null @@ -1,18 +0,0 @@ -panelizer = $panelizer; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('panelizer') - ); - } - - /** - * Reverts an entity view mode to a particular named default. - * - * @param \Drupal\Core\Entity\FieldableEntityInterface $entity - * The entity. - * @param string $view_mode - * The view mode. - * - * @return \Symfony\Component\HttpFoundation\Response - * An empty response. - * - * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException - */ - public function revertToDefault(FieldableEntityInterface $entity, $view_mode) { - // Get the bundle specific default display as a fallback. - $settings = $this->panelizer->getPanelizerSettings($entity->getEntityTypeId(), $entity->bundle(), $view_mode); - $default = $settings['default']; - // Check the entity for a documented default to which we should revert. - if ($entity->hasField('panelizer') && $entity->panelizer->first()) { - foreach ($entity->panelizer as $item) { - if ($item->view_mode == $view_mode && !empty($item->default)) { - $default = $item->default; - break; - } - } - } - // If we somehow ended up not having a default, throw an exception. - if (empty($default)) { - throw new BadRequestHttpException("Default name to revert to must be passed!"); - } - $this->panelizer->setPanelsDisplay($entity, $view_mode, $default); - return new Response(); - } - - /** - * Custom access checker for reverting an entity view mode to a named default. - * - * @param \Drupal\Core\Entity\FieldableEntityInterface $entity - * The entity. - * @param string $view_mode - * The view mode. - * @param \Drupal\Core\Session\AccountInterface $account - * The user account. - * - * @return \Drupal\Core\Access\AccessResultInterface - * The access result. - */ - public function accessRevertToDefault(FieldableEntityInterface $entity, $view_mode, AccountInterface $account) { - return AccessResult::allowedIf($this->panelizer->hasEntityPermission('revert to default', $entity, $view_mode, $account)); - } - -} \ No newline at end of file diff --git a/modules/distro/panelizer/src/Exception/PanelizerException.php b/modules/distro/panelizer/src/Exception/PanelizerException.php deleted file mode 100644 index 3bd76d949..000000000 --- a/modules/distro/panelizer/src/Exception/PanelizerException.php +++ /dev/null @@ -1,9 +0,0 @@ -entityTypeManager = $entity_type_manager; - $this->panelizer = $panelizer; - $this->panelsDisplayManager = $panels_display_manager; - $this->invalidator = $invalidator; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity_type.manager'), - $container->get('panelizer'), - $container->get('panels.display_manager'), - $container->get('cache_tags.invalidator') - ); - } - - /** - * {@inheritdoc} - */ - public function getQuestion() { - return 'Are you certain you want to delete this panelizer default?.'; - } - - /** - * {@inheritdoc} - */ - public function getCancelUrl() { - $bundle_entity_type = $this->entityTypeManager->getDefinition($this->entityTypeId)->getBundleEntityType(); - if ($this->viewMode == 'default') { - $route = "entity.entity_view_display.{$this->entityTypeId}.default"; - $arguments = [ - $bundle_entity_type => $this->bundle, - ]; - } - else { - $route = "entity.entity_view_display.{$this->entityTypeId}.view_mode"; - $arguments = [ - $bundle_entity_type => $this->bundle, - 'view_mode_name' => $this->viewMode, - ]; - } - return new Url($route, $arguments); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'panelizer_default_delete'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, $machine_name = NULL) { - list ( - $this->entityTypeId, - $this->bundle, - $this->viewMode, - $this->displayId - ) = explode('__', $machine_name); - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $display = $this->panelizer->getEntityViewDisplay($this->entityTypeId, $this->bundle, $this->viewMode); - $displays = $this->panelizer->getDefaultPanelsDisplays($this->entityTypeId, $this->bundle, $this->viewMode, $display); - unset($displays[$this->displayId]); - foreach ($displays as $key => $value) { - $displays[$key] = $this->panelsDisplayManager->exportDisplay($value); - } - $display->setThirdPartySetting('panelizer', 'displays', $displays); - $display->save(); - $form_state->setRedirectUrl($this->getCancelUrl()); - $tag = "panelizer_default:{$this->entityTypeId}:{$this->bundle}:{$this->viewMode}:{$this->displayId}"; - $this->invalidator->invalidateTags([$tag]); - } - -} diff --git a/modules/distro/panelizer/src/Form/PanelizerDefaultSelect.php b/modules/distro/panelizer/src/Form/PanelizerDefaultSelect.php deleted file mode 100644 index e1c98f14b..000000000 --- a/modules/distro/panelizer/src/Form/PanelizerDefaultSelect.php +++ /dev/null @@ -1,142 +0,0 @@ -panelizer = $panelizer; - $this->invalidator = $invalidator; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('panelizer'), - $container->get('cache_tags.invalidator') - ); - } - - /** - * {@inheritdoc} - */ - public function getQuestion() { - return 'Are you certain you want to set this panelizer default as the default for this bundle?.'; - } - - /** - * {@inheritdoc} - */ - public function getCancelUrl() { - $bundle_entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId)->getBundleEntityType(); - if ($this->viewMode == 'default') { - $route = "entity.entity_view_display.{$this->entityTypeId}.default"; - $arguments = [ - $bundle_entity_type => $this->bundle, - ]; - } - else { - $route = "entity.entity_view_display.{$this->entityTypeId}.view_mode"; - $arguments = [ - $bundle_entity_type => $this->bundle, - 'view_mode_name' => $this->viewMode, - ]; - } - return new Url($route, $arguments); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'panelizer_default_delete'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, $machine_name = NULL) { - list ( - $this->entityTypeId, - $this->bundle, - $this->viewMode, - $this->displayId - ) = explode('__', $machine_name); - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $display = $this->panelizer->getEntityViewDisplay($this->entityTypeId, $this->bundle, $this->viewMode); - $settings = $this->panelizer->getPanelizerSettings($this->entityTypeId, $this->bundle, $this->viewMode, $display); - $settings['default'] = $this->displayId; - $this->panelizer->setPanelizerSettings($this->entityTypeId, $this->bundle, $this->viewMode, $settings, $display); - $form_state->setRedirectUrl($this->getCancelUrl()); - $tag = "panelizer_default:{$this->entityTypeId}:{$this->bundle}:{$this->viewMode}"; - $this->invalidator->invalidateTags([$tag]); - } - -} diff --git a/modules/distro/panelizer/src/Form/PanelizerWizardContextConfigure.php b/modules/distro/panelizer/src/Form/PanelizerWizardContextConfigure.php deleted file mode 100644 index e98703099..000000000 --- a/modules/distro/panelizer/src/Form/PanelizerWizardContextConfigure.php +++ /dev/null @@ -1,77 +0,0 @@ -contextMapper = $container->get('ctools.context_mapper'); - - return $instance; - } - - /** - * {@inheritdoc} - */ - protected function getParentRouteInfo($cached_values) { - return ['panelizer.wizard.add.step', [ - 'machine_name' => $cached_values['id'], - 'step' => 'contexts', - ]]; - } - - /** - * {@inheritdoc} - */ - protected function getContexts($cached_values) { - $static_contexts = isset($cached_values['contexts']) ? $cached_values['contexts'] : []; - $static_contexts = $this->contextMapper->getContextValues($static_contexts); - return $static_contexts; - } - - /** - * {@inheritdoc} - */ - protected function addContext($cached_values, $context_id, ContextInterface $context) { - $cached_values['contexts'][$context_id] = [ - 'label' => $context->getContextDefinition()->getLabel(), - 'type' => $context->getContextDefinition()->getDataType(), - 'description' => $context->getContextDefinition()->getDescription(), - 'value' => strpos($context->getContextDefinition()->getDataType(), 'entity:') === 0 ? $context->getContextValue()->uuid() : $context->getContextValue(), - ]; - return $cached_values; - } - - /** - * {@inheritdoc} - */ - public function contextExists($value, $element, $form_state) { - return FALSE; - } - - /** - * {@inheritdoc} - */ - protected function disableMachineName($cached_values, $machine_name) { - return !empty($cached_values['contexts'][$machine_name]); - } - -} diff --git a/modules/distro/panelizer/src/Form/PanelizerWizardContextDeleteForm.php b/modules/distro/panelizer/src/Form/PanelizerWizardContextDeleteForm.php deleted file mode 100644 index e0d38575b..000000000 --- a/modules/distro/panelizer/src/Form/PanelizerWizardContextDeleteForm.php +++ /dev/null @@ -1,54 +0,0 @@ -getTempstore(); - $context = $cached_values['contexts'][$this->context_id]; - return $this->t('Are you sure you want to delete the context @label?', ['@label' => $context['label']]); - } - - /** - * {@inheritdoc} - */ - public function getCancelUrl() { - $cached_values = $this->getTempstore(); - - return new Url('panelizer.wizard.add.step', [ - 'machine_name' => $cached_values['id'], - 'step' => 'contexts', - ]); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $cached_values = $this->getTempstore(); - $context = $cached_values['contexts'][$this->context_id]; - \Drupal::messenger()->addMessage($this->t('The static context %label has been removed.', ['%label' => $context['label']])); - unset($cached_values['contexts'][$this->context_id]); - $this->setTempstore($cached_values); - parent::submitForm($form, $form_state); - } - -} diff --git a/modules/distro/panelizer/src/Form/PanelizerWizardContextForm.php b/modules/distro/panelizer/src/Form/PanelizerWizardContextForm.php deleted file mode 100644 index 9ebfbd871..000000000 --- a/modules/distro/panelizer/src/Form/PanelizerWizardContextForm.php +++ /dev/null @@ -1,133 +0,0 @@ -tempstoreFactory = $container->get('tempstore.shared'); - - return $instance; - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'panelizer_wizard_context_form'; - } - - /** - * {@inheritdoc} - */ - protected function getContextClass($cached_values) { - return PanelizerWizardContextConfigure::class; - } - - /** - * {@inheritdoc} - */ - protected function getRelationshipClass($cached_values) {} - - /** - * {@inheritdoc} - */ - protected function getContextAddRoute($cached_values) { - return 'panelizer.wizard.step.context.add'; - } - - /** - * {@inheritdoc} - */ - protected function getRelationshipAddRoute($cached_values) { - return 'panelizer.wizard.step.context.add'; - } - - /** - * {@inheritdoc} - */ - protected function getContexts($cached_values) { - return $cached_values['plugin']->getPattern()->getDefaultContexts($this->tempstoreFactory, $this->getTempstoreId(), $this->machine_name); - } - - /** - * {@inheritdoc} - */ - protected function getTempstoreId() { - return 'panelizer.wizard'; - } - - /** - * {@inheritdoc} - */ - protected function getContextOperationsRouteInfo($cached_values, $machine_name, $row) { - return ['panelizer.wizard.step.context', [ - 'machine_name' => $machine_name, - 'context_id' => $row, - ]]; - } - - /** - * {@inheritdoc} - */ - protected function getRelationshipOperationsRouteInfo($cached_values, $machine_name, $row) { - return ['panelizer.wizard.step.context', [ - 'machine_name' => $machine_name, - 'context_id' => $row, - ]]; - } - - /** - * {@inheritdoc} - */ - protected function isEditableContext($cached_values, $row) { - if (!isset($cached_values['contexts'][$row])) { - return FALSE; - } - $context = $cached_values['contexts'][$row]; - return !empty($context['value']); - } - - /** - * {@inheritdoc} - */ - public function addContext(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - $context = $form_state->getValue('context'); - $content = $this->formBuilder->getForm($this->getContextClass($cached_values), $context, $this->getTempstoreId(), $this->machine_name); - $content['#attached']['library'][] = 'core/drupal.dialog.ajax'; - list(, $route_parameters) = $this->getContextOperationsRouteInfo($cached_values, $this->machine_name, $context); - $content['submit']['#attached']['drupalSettings']['ajax'][$content['submit']['#id']]['url'] = Url::fromUri($this->getContextAddRoute($cached_values), ['query' => [FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]]); - $response = new AjaxResponse(); - $response->addCommand(new OpenModalDialogCommand($this->t('Add new context'), $content, ['width' => '700'])); - return $response; - } - -} diff --git a/modules/distro/panelizer/src/Form/PanelizerWizardGeneralForm.php b/modules/distro/panelizer/src/Form/PanelizerWizardGeneralForm.php deleted file mode 100644 index dcb84a989..000000000 --- a/modules/distro/panelizer/src/Form/PanelizerWizardGeneralForm.php +++ /dev/null @@ -1,154 +0,0 @@ -routeMatch = $route_match; - - if ($route_match->getRouteName() == 'panelizer.wizard.add') { - $this->entityTypeId = $route_match->getParameter('entity_type_id'); - $this->bundle = $route_match->getParameter('bundle'); - $this->viewMode = $route_match->getParameter('view_mode_name'); - } - $this->panelizer = $panelizer; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('current_route_match'), - $container->get('panelizer') - ); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'panelizer_wizard_general_form'; - } - - /** - * @param $machine_name - * @param $element - */ - public static function validateMachineName($machine_name, $element) { - // Attempt to load via the machine name and entity type. - if (isset($element['#machine_name']['prefix'])) { - $panelizer = \Drupal::service('panelizer'); - // Load the panels display variant. - $full_machine_name = $element['#machine_name']['prefix'] . '__' . $machine_name; - return $panelizer->getDefaultPanelsDisplayByMachineName($full_machine_name); - } - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */ - $plugin = $cached_values['plugin']; - - $form_state = new FormState(); - $form_state->setValues($form_state->getValue('variant_settings', [])); - $settings = $plugin->buildConfigurationForm([], $form_state); - - // If the entity view display supports custom Panelizer layouts, force use - // of the in-place editor. Right now, there is no other way to work with - // custom layouts. - if (isset($cached_values['id'])) { - list ($this->entityTypeId, $this->bundle, $this->viewMode) = explode('__', $cached_values['id']); - } - $panelizer_settings = $this->panelizer - ->getPanelizerSettings($this->entityTypeId, $this->bundle, $this->viewMode); - - if (!empty($panelizer_settings['custom'])) { - $settings['builder']['#default_value'] = 'ipe'; - $settings['builder']['#access'] = FALSE; - } - - $settings['#tree'] = TRUE; - $form['variant_settings'] = $settings; - return $form; - } - - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - if ($form_state->hasValue('id') && !isset($this->machine_name) && $form_state->has('machine_name_prefix')) { - $form_state->setValue('id', "{$form_state->get('machine_name_prefix')}__{$form_state->getValue('id')}"); - } - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */ - $plugin = $cached_values['plugin']; - $plugin->submitConfigurationForm($form['variant_settings'], (new FormState())->setValues($form_state->getValue('variant_settings', []))); - $configuration = $plugin->getConfiguration(); - $cached_values['plugin']->setConfiguration($configuration); - } - -} diff --git a/modules/distro/panelizer/src/Menu/AddDefaultLocalAction.php b/modules/distro/panelizer/src/Menu/AddDefaultLocalAction.php deleted file mode 100644 index c3b78f3fc..000000000 --- a/modules/distro/panelizer/src/Menu/AddDefaultLocalAction.php +++ /dev/null @@ -1,23 +0,0 @@ -pluginDefinition['route_parameters']['entity_type_id'] = $route_match->getCurrentRouteMatch()->getParameter('entity_type_id'); - $this->pluginDefinition['route_parameters']['bundle'] = $route_match->getCurrentRouteMatch()->getParameter('bundle'); - $this->pluginDefinition['route_parameters']['view_mode_name'] = $route_match->getCurrentRouteMatch()->getParameter('view_mode_name'); - return parent::getRouteParameters($route_match); - } - -} diff --git a/modules/distro/panelizer/src/Panelizer.php b/modules/distro/panelizer/src/Panelizer.php deleted file mode 100644 index d34b8de10..000000000 --- a/modules/distro/panelizer/src/Panelizer.php +++ /dev/null @@ -1,689 +0,0 @@ -entityTypeManager = $entity_type_manager; - $this->entityTypeBundleInfo = $entity_type_bundle_info; - $this->entityFieldManager = $entity_field_manager; - $this->fieldTypeManager = $field_type_manager; - $this->moduleHandler = $module_handler; - $this->currentUser = $current_user; - $this->panelizerEntityManager = $panelizer_entity_manager; - $this->panelsManager = $panels_manager; - $this->stringTranslation = $string_translation; - $this->contextMapper = $context_mapper; - } - - /** - * Gets the Panelizer entity plugin. - * - * @param $entity_type_id - * The entity type id. - * - * @return \Drupal\panelizer\Plugin\PanelizerEntityInterface - */ - protected function getEntityPlugin($entity_type_id) { - return $this->panelizerEntityManager->createInstance($entity_type_id, []); - } - - /** - * Load a Panels Display via an ID (Machine Name). - * - * @return \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant|NULL - * The default Panels display with the given name if it exists; otherwise - * NULL. - */ - public function getDefaultPanelsDisplayByMachineName($full_machine_name) { - list($entity_type, $bundle, $view_mode, $machine_name) = explode('__', $full_machine_name); - /** @var \Drupal\panelizer\Panelizer $panelizer */ - // @todo this $display_id looks all wrong to me since it's the name and view_mode. - return $this->getDefaultPanelsDisplay($machine_name, $entity_type, $bundle, $view_mode); - } - - /** - * {@inheritdoc} - */ - public function getEntityViewDisplay($entity_type_id, $bundle, $view_mode) { - // Check the existence and status of: - // - the display for the view mode, - // - the 'default' display. - $candidate_ids = []; - if ($view_mode != 'default') { - $candidate_ids[] = $entity_type_id . '.' . $bundle . '.' . $view_mode; - } - $candidate_ids[] = $entity_type_id . '.' . $bundle . '.default'; - $results = \Drupal::entityQuery('entity_view_display') - ->condition('id', $candidate_ids) - ->condition('status', TRUE) - ->execute(); - - // Select the first valid candidate display, if any. - $load_id = FALSE; - foreach ($candidate_ids as $candidate_id) { - if (isset($results[$candidate_id])) { - $load_id = $candidate_id; - break; - } - } - - // Use the selected display if any, or create a fresh runtime object. - $storage = $this->entityTypeManager->getStorage('entity_view_display'); - if ($load_id) { - $display = $storage->load($load_id); - } - else { - $display = $storage->create([ - 'targetEntityType' => $entity_type_id, - 'bundle' => $bundle, - 'mode' => $view_mode, - 'status' => TRUE, - ]); - } - - // Let modules alter the display. - $display_context = [ - 'entity_type' => $entity_type_id, - 'bundle' => $bundle, - 'view_mode' => $view_mode, - ]; - $this->moduleHandler->alter('entity_view_display', $display, $display_context); - - return $display; - } - - /** - * {@inheritdoc} - */ - public function getPanelsDisplay(FieldableEntityInterface $entity, $view_mode, EntityViewDisplayInterface $display = NULL) { - $settings = $this->getPanelizerSettings($entity->getEntityTypeId(), $entity->bundle(), $view_mode, $display); - if (($settings['custom'] || $settings['allow']) && isset($entity->panelizer) && $entity->panelizer->first()) { - /** @var \Drupal\Core\Field\FieldItemInterface[] $values */ - $values = []; - foreach ($entity->panelizer as $item) { - $values[$item->view_mode] = $item; - } - if (isset($values[$view_mode])) { - $panelizer_item = $values[$view_mode]; - // Check for a customized display first and use that if present. - if (!empty($panelizer_item->panels_display)) { - // @todo: validate schema after https://www.drupal.org/node/2392057 is fixed. - return $this->panelsManager->importDisplay($panelizer_item->panels_display, FALSE); - } - // If not customized, use the specified default. - if (!empty($panelizer_item->default)) { - // If we're using this magic key use the settings default. - if ($panelizer_item->default == '__bundle_default__') { - $default = $settings['default']; - } - else { - $default = $panelizer_item->default; - // Ensure the default still exists and if not fallback sanely. - $displays = $this->getDefaultPanelsDisplays($entity->getEntityTypeId(), $entity->bundle(), $view_mode); - if (!isset($displays[$default])) { - $default = $settings['default']; - } - } - $panels_display = $this->getDefaultPanelsDisplay($default, $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $display); - $this->setCacheTags($panels_display, $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $display, $default, $settings); - return $panels_display; - } - } - } - // If the field has no input to give us, use the settings default. - $panels_display = $this->getDefaultPanelsDisplay($settings['default'], $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $display); - $this->setCacheTags($panels_display, $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $display, $settings['default'], $settings); - return $panels_display; - } - - /** - * Properly determine the cache tags for a display and set them. - * - * @param \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display - * The panels display variant. - * @param string $entity_type_id - * The entity type id. - * @param string $bundle - * The bundle. - * @param string $view_mode - * The view mode. - * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface|NULL $display - * If the caller already has the correct display, it can optionally be - * passed in here so the Panelizer service doesn't have to look it up; - * otherwise, this argument can be omitted. - * @param $default - * The name of the panels display we are about to render. - * @param array $settings - * The default panelizer settings for this EntityViewDisplay. - */ - protected function setCacheTags(PanelsDisplayVariant $panels_display, $entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL, $default, array $settings) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - } - $display_mode = $display ? $display->getMode() : ''; - - if ($default == $settings['default']) { - $tags = ["{$panels_display->getStorageType()}:{$entity_type_id}:{$bundle}:{$display_mode}"]; - } - $tags[] = "{$panels_display->getStorageType()}:{$entity_type_id}:{$bundle}:{$display_mode}:$default"; - $panels_display->addCacheTags($tags); - } - - /** - * {@inheritdoc} - */ - public function setPanelsDisplay(FieldableEntityInterface $entity, $view_mode, $default, PanelsDisplayVariant $panels_display = NULL) { - $settings = $this->getPanelizerSettings($entity->getEntityTypeId(), $entity->bundle(), $view_mode); - if (($settings['custom'] || $settings['allow']) && isset($entity->panelizer)) { - $panelizer_item = NULL; - /** @var \Drupal\Core\Field\FieldItemInterface $item */ - foreach ($entity->panelizer as $item) { - if ($item->view_mode == $view_mode) { - $panelizer_item = $item; - break; - } - } - if (!$panelizer_item) { - $panelizer_item = $this->fieldTypeManager->createFieldItem($entity->panelizer, count($entity->panelizer)); - $panelizer_item->view_mode = $view_mode; - } - - // Note: We don't call $panels_display->setStorage() here because it will - // be set internally by PanelizerFieldType::postSave() which will know - // the real revision ID of the newly saved entity. - - $panelizer_item->panels_display = $panels_display ? $this->panelsManager->exportDisplay($panels_display) : []; - $panelizer_item->default = $default; - - // Create a new revision if possible. - if ($entity instanceof RevisionableInterface && $entity->getEntityType()->isRevisionable()) { - if ($entity->isDefaultRevision()) { - $entity->setNewRevision(TRUE); - } - } - - // Updates the changed time of the entity, if necessary. - if ($entity->getEntityType()->entityClassImplements(EntityChangedInterface::class)) { - $request_time = \Drupal::time()->getRequestTime(); - $entity->setChangedTime($request_time); - } - - $entity->panelizer[$panelizer_item->getName()] = $panelizer_item; - - $entity->save(); - } - else { - throw new PanelizerException("Custom overrides not enabled on this entity, bundle and view mode"); - } - } - - /** - * {@inheritdoc} - */ - public function getDefaultPanelsDisplays($entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - } - - // Get a list of all the defaults. - $display_config = $display->getThirdPartySetting('panelizer', 'displays', []); - $display_names = array_keys($display_config); - if (empty($display_names)) { - $display_names = ['default']; - } - - // Get each one individually. - $panels_displays = []; - foreach ($display_names as $name) { - if ($panels_display = $this->getDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode, $display)) { - $panels_displays[$name] = $panels_display; - } - } - - return $panels_displays; - } - - /** - * {@inheritdoc} - */ - public function getDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - // If we still don't find a display, then we won't find a Panelizer - // default for sure. - if (!$display) { - return NULL; - } - } - - $config = $display->getThirdPartySetting('panelizer', 'displays', []); - if (!empty($config[$name])) { - // Set a default just in case. - $config[$name]['builder'] = empty($config[$name]['builder']) ? 'standard' : $config[$name]['builder']; - // @todo: validate schema after https://www.drupal.org/node/2392057 is fixed. - $panels_display = $this->panelsManager->importDisplay($config[$name], FALSE); - } - else { - return NULL; - } - - // @todo: Should be set when written, not here! - $storage_id_parts = [ - $entity_type_id, - $bundle, - $view_mode, - $name, - ]; - $panels_display->setStorage('panelizer_default', implode(':', $storage_id_parts)); - - return $panels_display; - } - - /** - * {@inheritdoc} - */ - public function setDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode, PanelsDisplayVariant $panels_display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - if (!$display) { - throw new PanelizerException("Unable to find display for given entity type, bundle and view mode"); - } - - // Set this individual Panels display. - $panels_displays = $display->getThirdPartySetting('panelizer', 'displays', []); - $panels_displays[$name] = $this->panelsManager->exportDisplay($panels_display); - $display->setThirdPartySetting('panelizer', 'displays', $panels_displays); - - $display->save(); - } - - /** - * {@inheritdoc} - */ - public function getDisplayStaticContexts($name, $entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - // If we still don't find a display, then we won't find a Panelizer - // default for sure. - if (!$display) { - return NULL; - } - } - - $config = $display->getThirdPartySetting('panelizer', 'displays', []); - if (!empty($config[$name]) && !empty($config[$name]['static_context'])) { - return $this->contextMapper->getContextValues($config[$name]['static_context']); - } - return []; - } - - /** - * {@inheritdoc} - */ - public function setDisplayStaticContexts($name, $entity_type_id, $bundle, $view_mode, $contexts) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - if (!$display) { - throw new PanelizerException("Unable to find display for given entity type, bundle and view mode"); - } - - // Set this Panels display's static contexts. - $panels_displays = $display->getThirdPartySetting('panelizer', 'displays', []); - $panels_displays[$name]['static_context'] = $contexts; - $display->setThirdPartySetting('panelizer', 'displays', $panels_displays); - - $display->save(); - } - - /** - * {@inheritdoc} - */ - public function isPanelized($entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) { - if (!$this->getEntityPlugin($entity_type_id)) { - return FALSE; - } - - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - } - - return $display->getThirdPartySetting('panelizer', 'enable', FALSE); - } - - /** - * {@inheritdoc} - */ - public function getPanelizerSettings($entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - } - - $settings = [ - 'enable' => $this->isPanelized($entity_type_id, $bundle, $view_mode, $display), - 'custom' => $display->getThirdPartySetting('panelizer', 'custom', FALSE), - 'allow' => $display->getThirdPartySetting('panelizer', 'allow', FALSE), - 'default' => $display->getThirdPartySetting('panelizer', 'default', 'default'), - ]; - - // Make sure that the Panelizer field actually exists. - if ($settings['custom']) { - $fields = $this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle); - $settings['custom'] = isset($fields['panelizer']) && $fields['panelizer']->getType() == 'panelizer'; - } - - return $settings; - } - - /** - * {@inheritdoc} - */ - public function setPanelizerSettings($entity_type_id, $bundle, $view_mode, array $settings, EntityViewDisplayInterface $display = NULL) { - if (!$display) { - $display = $this->getEntityViewDisplay($entity_type_id, $bundle, $view_mode); - } - - $display->setThirdPartySetting('panelizer', 'enable', !empty($settings['enable'])); - $display->setThirdPartySetting('panelizer', 'custom', !empty($settings['enable']) && !empty($settings['custom'])); - $display->setThirdPartySetting('panelizer', 'allow', !empty($settings['enable']) && !empty($settings['allow'])); - $display->setThirdPartySetting('panelizer', 'default', $settings['default']); - - if (!empty($settings['enable'])) { - // Set the default display. - $displays = $display->getThirdPartySetting('panelizer', 'displays', []); - if (empty($displays['default'])) { - /** @var \Drupal\panelizer\Plugin\PanelizerEntityInterface $panelizer_entity_plugin */ - $panelizer_entity_plugin = $this->panelizerEntityManager->createInstance($display->getTargetEntityTypeId(), []); - $displays['default'] = $this->panelsManager->exportDisplay($panelizer_entity_plugin->getDefaultDisplay($display, $display->getTargetBundle(), $display->getMode())); - $settings['default'] = "{$display->getTargetEntityTypeId()}__{$display->getTargetBundle()}__{$view_mode}__default"; - $display->setThirdPartySetting('panelizer', 'displays', $displays); - } - - // Make sure the field exists. - if (($settings['custom'] || $settings['allow'])) { - $field_storage = $this->entityTypeManager->getStorage('field_storage_config')->load($entity_type_id . '.panelizer'); - if (!$field_storage) { - $field_storage = $this->entityTypeManager->getStorage('field_storage_config')->create([ - 'entity_type' => $entity_type_id, - 'field_name' => 'panelizer', - 'type' => 'panelizer', - 'cardinality' => -1, - 'settings' => [], - 'status' => TRUE, - ]); - $field_storage->save(); - } - - $field = $this->entityTypeManager->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.panelizer'); - if (!$field) { - $field = $this->entityTypeManager->getStorage('field_config')->create([ - 'field_storage' => $field_storage, - 'bundle' => $bundle, - 'label' => $this->t('Panelizer'), - 'settings' => [], - ]); - $field->save(); - } - } - } - - $display->save(); - } - - /** - * Get a list of all the Panelizer operations. - * - * @return array - * Associative array of the human-readable operation names, keyed by the - * path. - */ - protected function getOperations() { - return [ - 'content' => $this->t('Content'), - 'layout' => $this->t('Layout'), - 'revert' => $this->t('Revert to default'), - ]; - } - - /** - * {@inheritdoc} - */ - public function getPermissions() { - $permissions = []; - - // Only look at entity types that have a corresponding Panelizer plugin. - $entity_types = array_intersect_key( - $this->entityTypeManager->getDefinitions(), - $this->panelizerEntityManager->getDefinitions() - ); - - foreach ($entity_types as $entity_type_id => $entity_type) { - $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id); - foreach ($bundles as $bundle => $bundle_info) { - $permissions["administer panelizer $entity_type_id $bundle defaults"] = [ - 'title' => t('%entity_name %bundle_name: Administer Panelizer default panels, allowed content and settings.', [ - '%entity_name' => $entity_type->getLabel(), - '%bundle_name' => $bundle_info['label'], - ]), - 'description' => t('Users with this permission can fully administer panelizer for this entity bundle.'), - ]; - - foreach ($this->getOperations() as $path => $operation) { - $permissions["administer panelizer $entity_type_id $bundle $path"] = [ - 'title' => $this->t('%entity_name %bundle_name: Administer Panelizer @operation', [ - '%entity_name' => $entity_type->getLabel(), - '%bundle_name' => $bundle_info['label'], - '@operation' => $operation, - ]), - ]; - } - } - } - - ksort($permissions); - return $permissions; - } - - /** - * Check permission for an individual operation only. - * - * Doesn't check any of the baseline permissions that you need along with - * the operation permission. - * - * @param string $op - * The operation. - * @param string $entity_type_id - * The entity type id. - * @param string $bundle - * The bundle. - * @param \Drupal\Core\Session\AccountInterface $account - * The user account. - * - * @return bool - * TRUE if the user has permission; FALSE otherwise. - */ - protected function hasOperationPermission($op, $entity_type_id, $bundle, AccountInterface $account) { - switch ($op) { - case 'change content': - return $account->hasPermission("administer panelizer $entity_type_id $bundle content"); - - case 'change layout': - return $account->hasPermission("administer panelizer $entity_type_id $bundle layout"); - - case 'revert to default': - return $account->hasPermission("administer panelizer $entity_type_id $bundle revert"); - } - - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function hasEntityPermission($op, EntityInterface $entity, $view_mode, AccountInterface $account = NULL) { - if (!$account) { - $account = $this->currentUser->getAccount(); - } - - // Must be able to edit the entity. - if (!$entity->access('update', $account)) { - return FALSE; - } - - // Must have overrides enabled. - $panelizer_settings = $this->getPanelizerSettings($entity->getEntityTypeId(), $entity->bundle(), $view_mode); - if (empty($panelizer_settings['custom'])) { - return FALSE; - } - - // Check admin permission. - if ($account->hasPermission('administer panelizer')) { - return TRUE; - } - - // @todo: check field access too! - - // if ($op == 'revert to default') { - // // We already have enough permissions at this point. - // return TRUE; - // } - - return $this->hasOperationPermission($op, $entity->getEntityTypeId(), $entity->bundle(), $account); - } - - /** - * {@inheritdoc} - */ - public function hasDefaultPermission($op, $entity_type_id, $bundle, $view_mode, $default, AccountInterface $account = NULL) { - if (!$this->isPanelized($entity_type_id, $bundle, $view_mode)) { - return FALSE; - } - - if (!$account) { - $account = $this->currentUser->getAccount(); - } - - // Check admin permissions. - if ($account->hasPermission('administer panelizer')) { - return TRUE; - } - if ($account->hasPermission("administer panelizer $entity_type_id $bundle defaults")) { - return TRUE; - } - - return $this->hasOperationPermission($op, $entity_type_id, $bundle, $account); - } - -} diff --git a/modules/distro/panelizer/src/PanelizerEntityViewBuilder.php b/modules/distro/panelizer/src/PanelizerEntityViewBuilder.php deleted file mode 100644 index 5fa1e9710..000000000 --- a/modules/distro/panelizer/src/PanelizerEntityViewBuilder.php +++ /dev/null @@ -1,411 +0,0 @@ -entityTypeId = $entity_type->id(); - $this->entityType = $entity_type; - $this->entityTypeManager = $entity_type_manager; - $this->moduleHandler = $module_handler; - $this->panelizer = $panelizer; - $this->panelizerManager = $panelizer_manager; - $this->panelsManager = $panels_manager; - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity_type.manager'), - $container->get('module_handler'), - $container->get('panelizer'), - $container->get('plugin.manager.panelizer_entity'), - $container->get('panels.display_manager') - ); - } - - /** - * Get the Panelizer entity plugin. - * - * @return \Drupal\panelizer\Plugin\PanelizerEntityInterface|FALSE - */ - protected function getPanelizerPlugin() { - if (!isset($this->panelizerPlugin)) { - if (!$this->panelizerManager->hasDefinition($this->entityTypeId)) { - $this->panelizerPlugin = FALSE; - } - else { - $this->panelizerPlugin = $this->panelizerManager->createInstance($this->entityTypeId, []); - } - } - - return $this->panelizerPlugin; - } - - /** - * Check if Panelizer should be used for building this display. - * - * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display - * The display we're building. - * - * @return bool - */ - protected function isPanelizerEnabled(EntityViewDisplayInterface $display) { - return $display->getThirdPartySetting('panelizer', 'enable', FALSE); - } - - /** - * Gets the original view builder for this entity. - * - * @return \Drupal\Core\Entity\EntityViewBuilderInterface - * - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - */ - protected function getFallbackViewBuilder() { - return $this->entityTypeManager->getHandler($this->entityTypeId, 'fallback_view_builder'); - } - - /** - * Get the Panels display out of an the entity view display - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity. - * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display - * The display. - * @param $view_mode - * The view mode. - * - * @return \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant - * The Panels display. - */ - protected function getPanelsDisplay(EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { - return $this->panelizer->getPanelsDisplay($entity, $view_mode, $display); - } - - /** - * Returns the display objects used to render a set of entities. - * - * Wraps EntityViewDisplay::collectRenderDisplays() so we can mock it in - * tests. - * - * @param \Drupal\Core\Entity\FieldableEntityInterface[] $entities - * The entities being rendered. They should all be of the same entity type. - * @param string $view_mode - * The view mode being rendered. - * - * @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface[] - * The display objects to use to render the entities, keyed by entity - * bundle. - * - * @see EntityViewDisplay::collectRenderDisplays() - */ - protected function collectRenderDisplays($entities, $view_mode) { - return EntityViewDisplay::collectRenderDisplays($entities, $view_mode); - } - - /** - * Returns the entity context. - * - * Wraps creating new Context objects to avoid typed data in tests. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity. - * - * @return \Drupal\Core\Plugin\Context\Context - * The context. - */ - protected function getEntityContext(EntityInterface $entity) { - return new AutomaticContext(EntityContextDefinition::fromEntityTypeId($this->entityTypeId), $entity); - } - - /* - * Methods from EntityViewBuilderInterface. - */ - - /** - * {@inheritdoc} - */ - public function buildComponents(array &$build, array $entities, array $displays, $view_mode) { - $fallback_view_builder = $this->getFallbackViewBuilder(); - - $panelized_entities = []; - $fallback_entities = []; - /** - * @var string $id - * @var \Drupal\Core\Entity\EntityInterface $entity - */ - foreach ($entities as $id => $entity) { - $display = $displays[$entity->bundle()]; - if ($this->isPanelizerEnabled($display)) { - $panelized_entities[$id] = $entity; - } - else { - $fallback_entities[$id] = $entity; - } - } - - // Handle all the fallback entities first! - if (!empty($fallback_entities)) { - $fallback_view_builder->buildComponents($build, $fallback_entities, $displays, $view_mode); - } - - // Handle the panelized entities. - if (!empty($panelized_entities)) { - $this->moduleHandler - ->invokeAll('entity_prepare_view', [ - $this->entityTypeId, - $panelized_entities, - $displays, - $view_mode - ]); - } - } - - /** - * {@inheritdoc} - */ - public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - // Trigger hook_panelizer_pre_view_builder_alter(). - $this->moduleHandler->alter('panelizer_pre_view_builder', $view_mode, $entity, $langcode); - - $displays = $this->collectRenderDisplays([$entity], $view_mode); - $display = $displays[$entity->bundle()]; - - if (!$this->isPanelizerEnabled($display)) { - return $this->getFallbackViewBuilder()->view($entity, $view_mode, $langcode); - } - - $build = $this->buildMultiplePanelized([$entity->id() => $entity], $displays, $view_mode, $langcode); - return $build[$entity->id()]; - } - - /** - * {@inheritdoc} - */ - public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) { - $displays = $this->collectRenderDisplays($entities, $view_mode); - - $panelized_entities = []; - $fallback_entities = []; - foreach ($entities as $id => $entity) { - $display = $displays[$entity->bundle()]; - if ($this->isPanelizerEnabled($display)) { - $panelized_entities[$id] = $entity; - } - else { - $fallback_entities[$id] = $entity; - } - } - - $result = []; - if (!empty($fallback_entities)) { - $result += $this->getFallbackViewBuilder()->viewMultiple($fallback_entities, $view_mode, $langcode); - } - if (!empty($panelized_entities)) { - $result += $this->buildMultiplePanelized($panelized_entities, $displays, $view_mode, $langcode); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function resetCache(array $entities = NULL) { - $this->getFallbackViewBuilder()->resetCache($entities); - } - - /** - * {@inheritdoc} - */ - public function viewField(FieldItemListInterface $items, $display_options = []) { - return $this->getFallbackViewBuilder()->viewfield($items, $display_options); - } - - /** - * {@inheritdoc} - */ - public function viewFieldItem(FieldItemInterface $item, $display = []) { - return $this->getFallbackViewBuilder()->viewFieldItem($item, $display); - } - - /** - * {@inheritdoc} - */ - public function getCacheTags() { - return $this->getFallbackViewBuilder()->getCacheTags(); - } - - /* - * Methods for actually rendering the Panelized entities. - */ - - /** - * Build the render array for a list of panelized entities. - * - * @param \Drupal\Core\Entity\EntityInterface[] $entities - * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface[] $displays - * @param string $view_mode - * @param string|NULL $langcode - * - * @return array - */ - protected function buildMultiplePanelized(array $entities, array $displays, $view_mode, $langcode) { - $build = []; - - foreach ($entities as $id => $entity) { - $panels_display = $this->panelizer->getPanelsDisplay($entity, $view_mode, $displays[$entity->bundle()]); - $settings = $this->panelizer->getPanelizerSettings($entity->getEntityTypeId(), $entity->bundle(), $view_mode, $displays[$entity->bundle()]); - $panels_display->setContexts($this->panelizer->getDisplayStaticContexts($settings['default'], $entity->getEntityTypeId(), $entity->bundle(), $view_mode, $displays[$entity->bundle()])); - $build[$id] = $this->buildPanelized($entity, $panels_display, $view_mode, $langcode); - - // Allow modules to modify the render array. - $alter_types = [ - "{$this->entityTypeId}_view", - 'entity_view', - ]; - $this->moduleHandler->alter($alter_types, $build[$id], $entity, $displays[$entity->bundle()]); - } - - return $build; - } - - /** - * Build the render array for a single panelized entity. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * @param \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display - * @param string $view_mode - * @param string $langcode - * - * @return array - */ - protected function buildPanelized(EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode, $langcode) { - $contexts = $panels_display->getContexts(); - $contexts['@panelizer.entity_context:entity'] = $this->getEntityContext($entity); - $panels_display->setContexts($contexts); - - $build = [ - '#theme' => [ - 'panelizer_view_mode__' . $this->entityTypeId . '__' . $entity->id(), - 'panelizer_view_mode__' . $this->entityTypeId . '__' . $entity->bundle(), - 'panelizer_view_mode__' . $this->entityTypeId, - 'panelizer_view_mode', - ], - '#panelizer_plugin' => $this->getPanelizerPlugin(), - '#panels_display' => $panels_display, - '#entity' => $entity, - '#view_mode' => $view_mode, - '#langcode' => $langcode, - 'content' => $panels_display->build(), - ]; - - if (isset($build['content']['#title'])) { - $build['#title'] = $build['content']['#title']; - } - - // @todo: I'm sure more is necessary to get the cache contexts right... - $entity_metadata = CacheableMetadata::createFromObject($entity); - CacheableMetadata::createFromObject($panels_display)->merge($entity_metadata)->applyTo($build); - - $this->getPanelizerPlugin()->alterBuild($build, $entity, $panels_display, $view_mode); - - return $build; - } - -} diff --git a/modules/distro/panelizer/src/PanelizerInterface.php b/modules/distro/panelizer/src/PanelizerInterface.php deleted file mode 100644 index 76a472cfe..000000000 --- a/modules/distro/panelizer/src/PanelizerInterface.php +++ /dev/null @@ -1,243 +0,0 @@ -panelizerEntityManager = $panelizer_entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, $base_plugin_id) { - return new static( - $container->get('plugin.manager.panelizer_entity') - ); - } - - /** - * {@inheritdoc} - */ - public function getDerivativeDefinitions($base_plugin_definition) { - foreach ($this->panelizerEntityManager->getDefinitions() as $plugin_id => $definition) { - $this->derivatives["$plugin_id"] = $base_plugin_definition; - $this->derivatives["$plugin_id"]['appears_on'] = [ - "entity.entity_view_display.$plugin_id.default", - "entity.entity_view_display.$plugin_id.view_mode" - ]; - } - return parent::getDerivativeDefinitions($base_plugin_definition); - } - -} diff --git a/modules/distro/panelizer/src/Plugin/Field/FieldFormatter/PanelizerFormatter.php b/modules/distro/panelizer/src/Plugin/Field/FieldFormatter/PanelizerFormatter.php deleted file mode 100644 index 7eb366660..000000000 --- a/modules/distro/panelizer/src/Plugin/Field/FieldFormatter/PanelizerFormatter.php +++ /dev/null @@ -1,61 +0,0 @@ - $item) { - $elements[$delta] = [ - '#type' => 'item', - '#title' => $item->view_mode, - '#markup' => $this->viewValue($item), - ]; - } - - return $elements; - } - - /** - * Generate the output appropriate for one field item. - * - * @param \Drupal\Core\Field\FieldItemInterface $item - * One field item. - * - * @return string - * The textual output generated. - */ - protected function viewValue(FieldItemInterface $item) { - $description = ''; - if (!empty($item->default)) { - $description = $this->t('Using default called "@default"', ['@default' => $item->default]); - } - else { - $description = $this->t('Custom'); - } - return $description; - } - -} diff --git a/modules/distro/panelizer/src/Plugin/Field/FieldType/PanelizerFieldType.php b/modules/distro/panelizer/src/Plugin/Field/FieldType/PanelizerFieldType.php deleted file mode 100644 index 8f56c1b87..000000000 --- a/modules/distro/panelizer/src/Plugin/Field/FieldType/PanelizerFieldType.php +++ /dev/null @@ -1,143 +0,0 @@ -setLabel(new TranslatableMarkup('View mode')) - ->setSetting('case_sensitive', FALSE) - ->setRequired(TRUE); - $properties['default'] = DataDefinition::create('string') - ->setLabel(new TranslatableMarkup('Default name')) - ->setSetting('case_sensitive', FALSE) - ->setRequired(FALSE); - $properties['panels_display'] = MapDataDefinition::create('map') - ->setLabel(new TranslatableMarkup('Panels display')) - ->setRequired(FALSE); - - return $properties; - } - - /** - * @inheritDoc - */ - public static function mainPropertyName() { - return 'panels_display'; - } - - /** - * {@inheritdoc} - */ - public static function schema(FieldStorageDefinitionInterface $field_definition) { - $schema = [ - 'columns' => [ - 'view_mode' => [ - 'type' => 'varchar', - 'length' => '255', - 'binary' => FALSE, - ], - 'default' => [ - 'type' => 'varchar', - 'length' => '255', - 'binary' => FALSE, - ], - 'panels_display' => [ - 'type' => 'blob', - 'size' => 'normal', - 'serialize' => TRUE, - ], - ], - 'indexes' => [ - 'default' => ['default'], - ] - ]; - - return $schema; - } - - /** - * Returns the Panels display plugin manager. - * - * @return \Drupal\panels\PanelsDisplayManagerInterface - */ - protected static function getPanelsDisplayManager() { - return \Drupal::service('panels.display_manager'); - } - - /** - * {@inheritdoc} - */ - public static function generateSampleValue(FieldDefinitionInterface $field_definition) { - $panels_manager = static::getPanelsDisplayManager(); - $sample_display = $panels_manager->createDisplay(); - - $values['view_mode'] = 'default'; - $values['default'] = NULL; - $values['panels_display'] = $panels_manager->exportDisplay($sample_display); - return $values; - } - - /** - * {@inheritdoc} - */ - public function isEmpty() { - $panels_display = $this->get('panels_display')->getValue(); - $default = $this->get('default')->getValue(); - return empty($panels_display) && empty($default); - } - - /** - * {@inheritdoc} - */ - public function postSave($update) { - $panels_manager = $this->getPanelsDisplayManager(); - $panels_display_config = $this->get('panels_display')->getValue(); - - // If our field has custom panelizer display config data. - if (!empty($panels_display_config) && is_array($panels_display_config)) { - $panels_display = $panels_manager->importDisplay($panels_display_config, FALSE); - } - if (!empty($panels_display)) { - // Set the storage id to include the current revision id. - $entity = $this->getEntity(); - $storage_id_parts = [ - $entity->getEntityTypeId(), - $entity->id(), - $this->get('view_mode')->getValue() - ]; - if ($entity instanceof RevisionableInterface && $entity->getEntityType()->isRevisionable()) { - $storage_id_parts[] = $entity->getRevisionId(); - } - $panels_display->setStorage('panelizer_field', implode(':', $storage_id_parts)); - $this->set('panels_display', $panels_manager->exportDisplay($panels_display)); - - return TRUE; - } - } - -} diff --git a/modules/distro/panelizer/src/Plugin/Field/FieldWidget/PanelizerWidget.php b/modules/distro/panelizer/src/Plugin/Field/FieldWidget/PanelizerWidget.php deleted file mode 100644 index 1695b83a6..000000000 --- a/modules/distro/panelizer/src/Plugin/Field/FieldWidget/PanelizerWidget.php +++ /dev/null @@ -1,146 +0,0 @@ -getEntity(); - $entity_type_id = $entity->getEntityTypeId(); - $entity_view_modes = $this->getEntityDisplayRepository()->getViewModeOptionsByBundle($entity_type_id, $entity->bundle()); - - // Get the current values from the entity. - $values = []; - /** @var \Drupal\Core\Field\FieldItemInterface $item */ - foreach ($items as $item) { - $values[$item->view_mode] = [ - 'default' => $item->default, - 'panels_display' => $item->panels_display, - ]; - } - - // If any view modes are missing, then set the default. - $displays = []; - foreach ($entity_view_modes as $view_mode => $view_mode_info) { - $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode); - $displays[$view_mode] = $display->getThirdPartySetting('panelizer', 'displays', []); - // If we don't have a value, or the default is __bundle_default__ and our - // panels_display is empty, set the default to __bundle_default__. - if (!isset($values[$view_mode]) || ($values[$view_mode]['default'] == '__bundle_default__' && empty($values[$view_mode]['panels_display']))) { - if ($display->getThirdPartySetting('panelizer', 'enable', FALSE)) { - $values[$view_mode] = [ - 'default' => '__bundle_default__', - 'panels_display' => [], - ]; - } - } - } - - // Add elements to the form for each view mode. - $delta = 0; - foreach ($values as $view_mode => $value) { - $element[$delta]['view_mode'] = [ - '#type' => 'value', - '#value' => $view_mode, - ]; - - $settings = $this->getPanelizer()->getPanelizerSettings($entity_type_id, $entity->bundle(), $view_mode); - if (!empty($settings['allow'])) { - // We default to this option when the user hasn't previous interacted - // with the field. - $options = [ - '__bundle_default__' => $this->t('Current default display'), - ]; - foreach ($displays[$view_mode] as $machine_name => $panels_display) { - $options[$machine_name] = $panels_display['label']; - } - $element[$delta]['default'] = [ - '#title' => $entity_view_modes[$view_mode], - '#type' => 'select', - '#options' => $options, - '#default_value' => $value['default'], - ]; - // If we have a value in panels_display, prevent the user from - // interacting with the widget for the view modes that are overridden. - if (!empty($value['panels_display'])) { - $element[$delta]['default']['#disabled'] = TRUE; - $element[$delta]['default']['#options'][$value['default']] = $this->t('Custom Override'); - } - } - else { - $element[$delta]['default'] = [ - '#type' => 'value', - '#value' => $value['default'], - ]; - } - - $element[$delta]['panels_display'] = [ - '#type' => 'value', - '#value' => $value['panels_display'], - ]; - - $delta++; - } - - return $element; - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerNode.php b/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerNode.php deleted file mode 100644 index aeec6f9d1..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerNode.php +++ /dev/null @@ -1,81 +0,0 @@ -setPageTitle('[node:title]'); - - // Remove the 'title' block because it's covered already. - foreach ($panels_display->getRegionAssignments() as $region => $blocks) { - /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */ - foreach ($blocks as $block_id => $block) { - if ($block->getPluginId() == 'entity_field:node:title') { - $panels_display->removeBlock($block_id); - } - } - } - - if ($display->getComponent('links')) { - // @todo: add block for node links. - } - - if ($display->getComponent('langcode')) { - // @todo: add block for node language. - } - - return $panels_display; - } - - /** - * {@inheritdoc} - */ - public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - /** @var $entity \Drupal\node\Entity\Node */ - parent::alterBuild($build, $entity, $panels_display, $view_mode); - - if ($entity->id()) { - $build['#contextual_links']['node'] = [ - 'route_parameters' => ['node' => $entity->id()], - 'metadata' => ['changed' => $entity->getChangedTime()], - ]; - } - } - - /** - * {@inheritdoc} - */ - public function preprocessViewMode(array &$variables, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - parent::preprocessViewMode($variables, $entity, $panels_display, $view_mode); - - /** @var \Drupal\node\NodeInterface $node */ - $node = $entity; - - // Add node specific CSS classes. - if ($node->isPromoted()) { - $variables['attributes']['class'][] = 'node--promoted'; - } - if ($node->isSticky()) { - $variables['attributes']['class'][] = 'node--sticky'; - } - if (!$node->isPublished()) { - $variables['attributes']['class'][] = 'node--unpublished'; - } - } - -} \ No newline at end of file diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerTerm.php b/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerTerm.php deleted file mode 100644 index a78a7d347..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerTerm.php +++ /dev/null @@ -1,52 +0,0 @@ -setPageTitle('[term:name]'); - - // Remove the 'name' block because it's covered already. - foreach ($panels_display->getRegionAssignments() as $region => $blocks) { - /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */ - foreach ($blocks as $block_id => $block) { - if ($block->getPluginId() == 'entity_field:taxonomy_term:name') { - $panels_display->removeBlock($block_id); - } - } - } - - return $panels_display; - } - - /** - * {@inheritdoc} - */ - public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - /** @var $entity \Drupal\taxonomy\Entity\Term */ - parent::alterBuild($build, $entity, $panels_display, $view_mode); - - if ($entity->id()) { - $build['#contextual_links']['taxonomy_term'] = [ - 'route_parameters' => ['taxonomy_term' => $entity->id()], - 'metadata' => ['changed' => $entity->getChangedTime()], - ]; - } - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerUser.php b/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerUser.php deleted file mode 100644 index c2f84f213..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntity/PanelizerUser.php +++ /dev/null @@ -1,76 +0,0 @@ -setPageTitle('[user:name]'); - - // Remove the 'name' block because it's covered already. - foreach ($panels_display->getRegionAssignments() as $region => $blocks) { - /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */ - foreach ($blocks as $block_id => $block) { - if ($block->getPluginId() == 'entity_field:user:name') { - $panels_display->removeBlock($block_id); - } - } - } - - if ($display->getComponent('member_for')) { - // @todo: add block for 'Member for'. - } - - return $panels_display; - } - - /** - * {@inheritdoc} - */ - public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - /** @var $entity \Drupal\user\Entity\User */ - parent::alterBuild($build, $entity, $panels_display, $view_mode); - - if ($entity->id()) { - $build['#contextual_links']['user'] = [ - 'route_parameters' => ['user' => $entity->id()], - 'metadata' => ['changed' => $entity->getChangedTime()], - ]; - } - - // This function adds a default alt tag to the user_picture field to - // maintain accessibility. - if (user_picture_enabled() && !empty($build['content']['content'])) { - foreach (Element::children($build['content']['content']) as $key) { - if (isset($build['content']['content'][$key]['content']['field'])) { - foreach (Element::children($build['content']['content'][$key]['content']['field']) as $field_key) { - if ($build['content']['content'][$key]['content']['field']['#field_name'] == 'user_picture') { - if (empty($build['content']['content'][$key]['content']['field'][$field_key]['#item_attributes'])) { - $build['content']['content'][$key]['content']['field'][$field_key]['#item_attributes'] = [ - 'alt' => \Drupal::translation() - ->translate('Profile picture for user @username', ['@username' => $entity->getUsername()]) - ]; - } - } - } - } - } - } - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntityBase.php b/modules/distro/panelizer/src/Plugin/PanelizerEntityBase.php deleted file mode 100644 index 30a8b538f..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntityBase.php +++ /dev/null @@ -1,133 +0,0 @@ -panelsManager = $panels_manager; - $this->entityFieldManager = $entity_field_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('panels.display_manager'), - $container->get('entity_field.manager') - ); - } - - /** - * {@inheritdoc} - */ - public function getDefaultDisplay(EntityViewDisplayInterface $display, $bundle, $view_mode) { - $panels_display = $this->panelsManager->createDisplay(); - - $panels_display->setConfiguration(['label' => $this->t('Default')] + $panels_display->getConfiguration()); - $panels_display->setLayout('layout_onecol'); - // @todo: For now we always use the IPE, but we should support not using the ipe. - $panels_display->setBuilder('ipe'); - $panels_display->setPattern('panelizer'); - - // Add all the visible fields to the Panel. - $entity_type_id = $this->getPluginId(); - /** - * @var string $field_name - * @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition - */ - foreach ($this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_definition) { - // Skip the Panelizer field. - if ($field_definition->getType() == 'panelizer') { - continue; - } - - if ($component = $display->getComponent($field_name)) { - $weight = $component['weight']; - unset($component['weight']); - - $panels_display->addBlock([ - 'id' => 'entity_field:' . $entity_type_id . ':' . $field_name, - 'label' => $field_definition->getLabel(), - 'provider' => 'ctools_block', - 'label_display' => '0', - 'formatter' => $component, - 'context_mapping' => [ - 'entity' => '@panelizer.entity_context:entity', - ], - 'region' => 'content', - 'weight' => $weight, - ]); - } - } - - return $panels_display; - } - - /** - * {@inheritdoc} - */ - public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - // By default, do nothing! - } - - /** - * {@inheritdoc} - */ - public function preprocessViewMode(array &$variables, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) { - $entity_type_id = $this->getPluginId(); - - // Add some default classes. - $variables['attributes']['class'][] = $entity_type_id; - $variables['attributes']['class'][] = $entity_type_id . '--type-' . $entity->bundle(); - $variables['attributes']['class'][] = $entity_type_id . '--view-mode-' . $view_mode; - $variables['attributes']['class'][] = 'clearfix'; - - // Don't render the title in the template - if ($view_mode == 'full') { - $variables['title'] = ''; - } - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntityInterface.php b/modules/distro/panelizer/src/Plugin/PanelizerEntityInterface.php deleted file mode 100644 index 189e2db3c..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntityInterface.php +++ /dev/null @@ -1,70 +0,0 @@ -alterInfo('panelizer_entity_info'); - $this->setCacheBackend($cache_backend, 'panelizer_entity_plugins'); - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelizerEntityManagerInterface.php b/modules/distro/panelizer/src/Plugin/PanelizerEntityManagerInterface.php deleted file mode 100644 index 4b6d4716e..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelizerEntityManagerInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -setLabel($this->t('Entity being panelized')); - $contexts['@panelizer.entity_context:entity'] = new AutomaticContext($entity_definition); - $user_definition = EntityContextDefinition::fromEntityTypeId('user')->setLabel($this->t('Current user')); - $contexts['current_user'] = new Context($user_definition); - return $contexts + parent::getDefaultContexts($tempstore, $tempstore_id, $machine_name); - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php b/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php deleted file mode 100644 index 952845659..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerDefaultPanelsStorage.php +++ /dev/null @@ -1,191 +0,0 @@ -entityTypeManager = $entity_type_manager; - $this->panelizer = $panelizer; - parent::__construct($configuration, $plugin_id, $plugin_definition); - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager'), - $container->get('panelizer') - ); - } - - /** - * Converts the storage id into its component parts. - * - * @param string $id - * The storage id. There are two formats that can potentially be used: - * - The first is the normal format that we actually store: - * "entity_type_id:bundle:view_mode:name" - * - The second is a special internal format we use in the IPE so we can - * correctly set context: - * "*entity_type_id:entity_id:view_mode:name" - * - * @return array - * An array with 4 or 5 items: - * - Entity type id: string - * - Bundle name: string - * - View mode: string - * - Default name: string - * - Entity: \Drupal\Core\Entity\EntityInterface|NULL - * - * @throws \Drupal\panelizer\Exception\PanelizerException - */ - protected function parseId($id) { - list ($entity_type_id, $part_two, $view_mode, $name) = explode(':', $id); - - if (strpos($entity_type_id, '*') === 0) { - $entity_type_id = substr($entity_type_id, 1); - $storage = $this->entityTypeManager->getStorage($entity_type_id); - if ($entity = $storage->load($part_two)) { - $bundle = $entity->bundle(); - } - else { - throw new PanelizerException("Unable to load $entity_type_id with id $part_two"); - } - } - else { - $entity = NULL; - $bundle = $part_two; - } - - return [$entity_type_id, $bundle, $view_mode, $name, $entity]; - } - - /** - * Returns the entity context. - * - * Wraps creating new Context objects to avoid typed data in tests. - * - * @param string $entity_type_id - * The entity type id. - * @param \Drupal\Core\Entity\EntityInterface|NULL $entity - * The entity. - * - * @return \Drupal\Core\Plugin\Context\Context[] - * The available contexts. - */ - protected function getEntityContext($entity_type_id, EntityInterface $entity = NULL) { - $contexts = []; - // Set a placeholder context so that the calling code knows that we need - // an entity context. If we have the value available, then we actually set - // the context value. - $contexts['@panelizer.entity_context:entity'] = new AutomaticContext(EntityContextDefinition::fromEntityTypeId($entity_type_id), $entity); - return $contexts; - } - - - - /** - * {@inheritdoc} - */ - public function load($id) { - try { - list ($entity_type_id, $bundle, $view_mode, $name, $entity) = $this->parseId($id); - if ($panels_display = $this->panelizer->getDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode)) { - $contexts = $this->getEntityContext($entity_type_id, $entity); - $contexts = $contexts + $this->panelizer->getDisplayStaticContexts($name, $entity_type_id, $bundle, $view_mode); - $panels_display->setContexts($contexts); - return $panels_display; - } - } - catch (PanelizerException $e) { - // Do nothing to fallback on returning NULL. - } - } - - /** - * {@inheritdoc} - */ - public function save(PanelsDisplayVariant $panels_display) { - $id = $panels_display->getStorageId(); - try { - list ($entity_type_id, $bundle, $view_mode, $name) = $this->parseId($id); - $this->panelizer->setDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode, $panels_display); - } - catch (PanelizerException $e) { - throw new \Exception("Couldn't find Panelizer default to store Panels display"); - } - } - - /** - * {@inheritdoc} - */ - public function access($id, $op, AccountInterface $account) { - try { - list ($entity_type_id, $bundle, $view_mode, $name) = $this->parseId($id); - } - catch (PanelizerException $e) { - return AccessResult::forbidden(); - } - - if ($panels_display = $this->panelizer->getDefaultPanelsDisplay($name, $entity_type_id, $bundle, $view_mode)) { - if ($op == 'change layout') { - if ($this->panelizer->hasDefaultPermission('change layout', $entity_type_id, $bundle, $view_mode, $name, $account)) { - return AccessResult::allowed(); - } - } - else if ($op == 'read' || $this->panelizer->hasDefaultPermission('change content', $entity_type_id, $bundle, $view_mode, $name, $account)) { - return AccessResult::allowed(); - } - } - - return AccessResult::forbidden(); - } - -} diff --git a/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php b/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php deleted file mode 100644 index 15d113522..000000000 --- a/modules/distro/panelizer/src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php +++ /dev/null @@ -1,195 +0,0 @@ -entityTypeManager = $entity_type_manager; - $this->panelizer = $panelizer; - parent::__construct($configuration, $plugin_id, $plugin_definition); - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager'), - $container->get('panelizer') - ); - } - - /** - * Gets the underlying entity from storage. - * - * @param $id - * The storage service id. - * - * @return \Drupal\Core\Entity\EntityInterface|NULL - */ - protected function loadEntity($id) { - list ($entity_type, $id, , $revision_id) = array_pad(explode(':', $id), 4, NULL); - - $storage = $this->entityTypeManager->getStorage($entity_type); - if ($revision_id) { - $entity = $storage->loadRevision($revision_id); - } - else { - $entity = $storage->load($id); - } - - return $entity; - } - - /** - * Returns the entity context. - * - * Wraps creating new Context objects to avoid typed data in tests. - * - * @param string $entity_type_id - * The entity type id. - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity. - * - * @return \Drupal\Core\Plugin\Context\Context - * The context. - */ - protected function getEntityContext($entity_type_id, EntityInterface $entity) { - return new AutomaticContext(EntityContextDefinition::fromEntityTypeId($entity_type_id), $entity); - } - - /** - * {@inheritdoc} - */ - public function load($id) { - if ($entity = $this->loadEntity($id)) { - list ($entity_type_id, , $view_mode) = explode(':', $id); - if ($panels_display = $this->panelizer->getPanelsDisplay($entity, $view_mode)) { - // Set the entity as a context on the Panels display. - $contexts = [ - '@panelizer.entity_context:entity' => $this->getEntityContext($entity_type_id, $entity), - ]; - $panels_display->setContexts($contexts); - return $panels_display; - } - } - } - - /** - * {@inheritdoc} - */ - public function save(PanelsDisplayVariant $panels_display) { - $id = $panels_display->getStorageId(); - if ($entity = $this->loadEntity($id)) { - list (,, $view_mode) = explode(':', $id); - // If we're dealing with an entity that has a documented default, we - // don't want to lose that information when we save our customizations. - // This enables us to revert to the correct default at a later date. - if ($entity instanceof FieldableEntityInterface) { - $default = NULL; - if ($entity->hasField('panelizer') && $entity->panelizer->first()) { - foreach ($entity->panelizer as $item) { - if ($item->view_mode == $view_mode) { - $default = $item->default; - break; - } - } - } - try { - $this->panelizer->setPanelsDisplay($entity, $view_mode, $default, $panels_display); - } - catch (PanelizerException $e) { - // Translate to expected exception type. - throw new \Exception($e->getMessage()); - } - } - } - else { - throw new \Exception("Couldn't find entity to store Panels display on"); - } - } - - /** - * {@inheritdoc} - */ - public function access($id, $op, AccountInterface $account) { - if ($entity = $this->loadEntity($id)) { - $access = AccessResult::neutral() - ->addCacheableDependency($account); - - // We do not support "create", as this method's interface dictates, - // because we work with existing entities here. - $entity_operations = [ - 'read' => 'view', - 'update' => 'update', - 'delete'=> 'delete', - 'change layout' => 'update', - ]; - // Do not add entity cacheability metadata to the forbidden result, - // because it depends on the Panels operation, and not on the entity. - $access->orIf(isset($entity_operations[$op]) ? $entity->access($entity_operations[$op], $account, TRUE) : AccessResult::forbidden()); - - if (!$access->isForbidden() && $entity instanceof FieldableEntityInterface) { - list (,, $view_mode) = explode(':', $id); - if ($op == 'change layout') { - if ($this->panelizer->hasEntityPermission('change layout', $entity, $view_mode, $account)) { - return $access->orIf(AccessResult::allowed()); - } - } - else if ($op == 'read' || $this->panelizer->hasEntityPermission('change content', $entity, $view_mode, $account)) { - return $access->orIf(AccessResult::allowed()); - } - } - } - - return AccessResult::forbidden(); - } - -} diff --git a/modules/distro/panelizer/src/Wizard/PanelizerAddWizard.php b/modules/distro/panelizer/src/Wizard/PanelizerAddWizard.php deleted file mode 100644 index 85513e8ce..000000000 --- a/modules/distro/panelizer/src/Wizard/PanelizerAddWizard.php +++ /dev/null @@ -1,72 +0,0 @@ -set('machine_name_prefix', "{$entity_type_id}__{$bundle}__{$view_mode_name}"); - } - $form = parent::buildForm($form, $form_state); - $cached_values = $form_state->getTemporaryValue('wizard'); - $cached_values['id'] = $this->getMachineName(); - // Some variants like PanelsDisplayVariant need this. Set it to empty. - $cached_values['access'] = []; - $form_state->setTemporaryValue('wizard', $cached_values); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $operations = array_map('strval', [ - $this->getNextOp(), - $this->t('Update'), - $this->t('Update and save'), - $this->t('Save'), - ]); - - if (in_array($form_state->getValue('op'), $operations)) { - $cached_values = $form_state->getTemporaryValue('wizard'); - if ($form_state->hasValue('label')) { - $config = $cached_values['plugin']->getConfiguration(); - $config['label'] = $form_state->getValue('label'); - $cached_values['plugin']->setConfiguration($config); - } - if ($form_state->hasValue('id')) { - $cached_values['id'] = $form_state->getValue('id'); - /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */ - $plugin = $cached_values['plugin']; - $plugin->setStorage($plugin->getStorageType(), $cached_values['id']); - } - } - parent::submitForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function finish(array &$form, FormStateInterface $form_state) { - parent::finish($form, $form_state); - $cached_values = $form_state->getTemporaryValue('wizard'); - $form_state->setRedirect('panelizer.wizard.edit', ['machine_name' => $cached_values['id'], 'step' => 'content']); - } - -} diff --git a/modules/distro/panelizer/src/Wizard/PanelizerEditWizard.php b/modules/distro/panelizer/src/Wizard/PanelizerEditWizard.php deleted file mode 100644 index fd68561b9..000000000 --- a/modules/distro/panelizer/src/Wizard/PanelizerEditWizard.php +++ /dev/null @@ -1,225 +0,0 @@ -getMachineName(); - list($entity_type, $bundle, $view_mode, $display_id) = explode('__', $this->getMachineName()); - $panelizer = \Drupal::service('panelizer'); - // Load the panels display variant. - /** @var \Drupal\panelizer\Panelizer $panelizer */ - // @todo this $display_id looks all wrong to me since it's the name and view_mode. - $variant_plugin = $panelizer->getDefaultPanelsDisplay($display_id, $entity_type, $bundle, $view_mode); - $cached_values['plugin'] = $variant_plugin; - $cached_values['label'] = $cached_values['plugin']->getConfiguration()['label']; - - $display = $panelizer->getEntityViewDisplay($entity_type, $bundle, $view_mode); - $config = $display->getThirdPartySetting('panelizer', 'displays', []); - if (!empty($config[$display_id]['static_context'])) { - $cached_values['contexts'] = $config[$display_id]['static_context']; - } - return $cached_values; - } - - /** - * {@inheritdoc} - */ - protected function customizeForm(array $form, FormStateInterface $form_state) { - // The page actions. - $form['wizard_actions'] = [ - '#theme' => 'links', - '#links' => [], - '#attributes' => [ - 'class' => ['inline'], - ] - ]; - - // The tree of wizard steps. - $form['wizard_tree'] = [ - '#theme' => ['panelizer_wizard_tree'], - '#wizard' => $this, - '#cached_values' => $form_state->getTemporaryValue('wizard'), - ]; - - $form['#theme'] = 'panelizer_wizard_form'; - $form['#attached']['library'][] = 'panelizer/wizard_admin'; - $form = parent::customizeForm($form, $form_state); - return $form; - } - - /** - * {@inheritdoc} - */ - protected function actions(FormInterface $form_object, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - $operation = $this->getOperation($cached_values); - - $actions = []; - - $actions['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Update'), - '#validate' => [ - '::populateCachedValues', - [$form_object, 'validateForm'], - ], - '#submit' => [ - [$form_object, 'submitForm'], - ], - ]; - - $actions['update_and_save'] = [ - '#type' => 'submit', - '#value' => $this->t('Update and save'), - '#button_type' => 'primary', - '#validate' => [ - '::populateCachedValues', - [$form_object, 'validateForm'], - ], - '#submit' => [ - [$form_object, 'submitForm'], - ], - ]; - - $actions['finish'] = [ - '#type' => 'submit', - '#value' => $this->t('Save'), - '#validate' => [ - '::populateCachedValues', - [$form_object, 'validateForm'], - ], - '#submit' => [ - [$form_object, 'submitForm'], - ], - ]; - - $actions['cancel'] = [ - '#type' => 'submit', - '#value' => $this->t('Cancel'), - '#submit' => [ - '::clearTempstore' - ], - ]; - - // Add any submit or validate functions for the step and the global ones. - foreach (['submit', 'update_and_save', 'finish'] as $button) { - if (isset($operation['validate'])) { - $actions[$button]['#validate'] = array_merge($actions[$button]['#validate'], $operation['validate']); - } - $actions[$button]['#validate'][] = '::validateForm'; - if (isset($operation['submit'])) { - $actions[$button]['#submit'] = array_merge($actions[$button]['#submit'], $operation['submit']); - } - $actions[$button]['#submit'][] = '::submitForm'; - } - $actions['update_and_save']['#submit'][] = '::finish'; - $actions['finish']['#submit'][] = '::finish'; - - if ($form_state->get('ajax')) { - $cached_values = $form_state->getTemporaryValue('wizard'); - $ajax_parameters = $this->getNextParameters($cached_values); - $ajax_parameters['step'] = $this->getStep($cached_values); - $ajax_url = Url::fromRoute($this->getRouteName(), $ajax_parameters); - $ajax_options = [ - 'query' => $this->getRequest()->query->all() + [ - FormBuilderInterface::AJAX_FORM_REQUEST => TRUE, - ], - ]; - $actions['submit']['#ajax'] = [ - 'callback' => '::ajaxSubmit', - 'url' => $ajax_url, - 'options' => $ajax_options, - ]; - $actions['update_and_save']['#ajax'] = [ - 'callback' => '::ajaxFinish', - 'url' => $ajax_url, - 'options' => $ajax_options, - ]; - $actions['finish']['#ajax'] = [ - 'callback' => '::ajaxFinish', - 'url' => $ajax_url, - 'options' => $ajax_options, - ]; - } - - return $actions; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $operations = array_map('strval', [ - $this->getNextOp(), - $this->t('Update'), - $this->t('Update and save'), - $this->t('Save'), - ]); - - if (in_array($form_state->getValue('op'), $operations)) { - $cached_values = $form_state->getTemporaryValue('wizard'); - if ($form_state->hasValue('label')) { - $config = $cached_values['plugin']->getConfiguration(); - $config['label'] = $form_state->getValue('label'); - $cached_values['plugin']->setConfiguration($config); - } - if ($form_state->hasValue('id')) { - $cached_values['id'] = $form_state->getValue('id'); - } - if (is_null($this->machine_name) && !empty($cached_values['id'])) { - $this->machine_name = $cached_values['id']; - } - $this->getTempstore()->set($this->getMachineName(), $cached_values); - if (!$form_state->get('ajax')) { - $form_state->setRedirect($this->getRouteName(), $this->getNextParameters($cached_values)); - } - } - } - - /** - * Clears the temporary store. - * - * @param array $form - * @param \Drupal\Core\Form\FormStateInterface $form_state - */ - public function clearTempstore(array &$form, FormStateInterface $form_state) { - $this->getTempstore()->delete($this->getMachineName()); - list($entity_type_id, $bundle, $view_mode) = explode('__', $this->getMachineName()); - $bundle_entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getBundleEntityType(); - if ($view_mode == 'default') { - $route = "entity.entity_view_display.{$entity_type_id}.default"; - $arguments = [ - $bundle_entity_type => $bundle, - ]; - } - else { - $route = "entity.entity_view_display.{$entity_type_id}.view_mode"; - $arguments = [ - $bundle_entity_type => $bundle, - 'view_mode_name' => $view_mode, - ]; - } - $form_state->setRedirect($route, $arguments); - } - -} diff --git a/modules/distro/panelizer/src/Wizard/PanelizerWizardBase.php b/modules/distro/panelizer/src/Wizard/PanelizerWizardBase.php deleted file mode 100644 index ac446b4c8..000000000 --- a/modules/distro/panelizer/src/Wizard/PanelizerWizardBase.php +++ /dev/null @@ -1,168 +0,0 @@ -getTemporaryValue('wizard'); - // Get the current form operation. - $operation = $this->getOperation($cached_values); - $operations = $this->getOperations($cached_values); - $default_operation = reset($operations); - - // Get the machine name. There are two ways we can get this data. - $storage = $form_state->getStorage(); - $prefix = isset($storage['machine_name_prefix']) ? $storage['machine_name_prefix'] : $form_state->getTemporaryValue('wizard')['id']; - - if ($operation['form'] == $default_operation['form']) { - // Create id and label form elements. - $form['name'] = [ - '#type' => 'fieldset', - '#attributes' => ['class' => ['fieldset-no-legend']], - '#title' => $this->getWizardLabel(), - ]; - $form['name']['label'] = [ - '#type' => 'textfield', - '#title' => $this->getMachineLabel(), - '#required' => TRUE, - '#size' => 32, - '#default_value' => !empty($cached_values['label']) ? $cached_values['label'] : '', - '#maxlength' => 255, - '#disabled' => !empty($cached_values['label']), - ]; - $form['name']['id'] = [ - '#type' => 'machine_name', - '#maxlength' => 128, - '#machine_name' => [ - 'source' => ['name', 'label'], - 'exists' => $this->exists(), - 'prefix' => $prefix, - ], - '#description' => $this->t('A unique machine-readable name for this display. It must only contain lowercase letters, numbers, and underscores.'), - '#default_value' => !empty($cached_values['id']) ? $cached_values['id'] : '', - '#disabled' => !empty($cached_values['id']), - ]; - } - return $form; - } - - /** - * {@inheritdoc} - */ - public function getWizardLabel() { - return $this->t('Wizard Information'); - } - - /** - * {@inheritdoc} - */ - public function getMachineLabel() { - return $this->t('Wizard name'); - } - - /** - * {@inheritdoc} - */ - public function exists() { - return '\Drupal\panelizer\Form\PanelizerWizardGeneralForm::validateMachineName'; - } - - /** - * {@inheritdoc} - */ - public function getOperations($cached_values) { - $operations = [ - 'general' => [ - 'form' => PanelizerWizardGeneralForm::class, - 'title' => $this->t('General settings'), - ], - 'contexts' => [ - 'form' => PanelizerWizardContextForm::class, - 'title' => $this->t('Contexts'), - ], - ]; - - // Add any wizard operations from the plugin itself. - foreach ($cached_values['plugin']->getWizardOperations($cached_values) as $name => $operation) { - $operations[$name] = $operation; - } - - // Change the class that manages the Content step. - if (isset($operations['content'])) { - //$operations['content']['form'] = PanelizerWizardContentForm::class; - } - - return $operations; - } - - public function initValues() { - $cached_values = parent::initValues(); - $cached_values['access'] = new PanelizerUIAccess(); - if (empty($cached_values['plugin'])) { - /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */ - $plugin = \Drupal::service('plugin.manager.display_variant')->createInstance('panels_variant'); - $plugin->setPattern('panelizer'); - $plugin->setBuilder('ipe'); - $plugin->setStorage('panelizer_default', 'TEMPORARY_STORAGE_ID'); - $cached_values['plugin'] = $plugin; - } - if (empty($cached_values['contexts'])) { - $cached_values['contexts'] = []; - } - return $cached_values; - } - - - /** - * {@inheritdoc} - */ - public function finish(array &$form, FormStateInterface $form_state) { - $cached_values = $form_state->getTemporaryValue('wizard'); - - // Save the panels display mode and its custom settings as third party - // data of the display mode for this entity+bundle+display. - /** @var \Drupal\panelizer\Panelizer $panelizer */ - $panelizer = \Drupal::service('panelizer'); - /** @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface $invalidator */ - $invalidator = \Drupal::service('cache_tags.invalidator'); - list($entity_type, $bundle, $view_mode, $display_id) = explode('__', $cached_values['id']); - $panelizer->setDefaultPanelsDisplay($display_id, $entity_type, $bundle, $view_mode, $cached_values['plugin']); - $panelizer->setDisplayStaticContexts($display_id, $entity_type, $bundle, $view_mode, $cached_values['contexts']); - - parent::finish($form, $form_state); - $form_state->setRedirect('panelizer.wizard.edit', ['machine_name' => $cached_values['id']]); - $invalidator->invalidateTags(["panelizer_default:$entity_type:$bundle:$view_mode:$display_id"]); - } - - /** - * Wraps the context mapper. - * - * @return \Drupal\ctools\ContextMapperInterface - */ - protected function getContextMapper() { - return \Drupal::service('ctools.context_mapper'); - } - - /** - * {@inheritdoc} - */ - protected function getContexts($cached_values) { - return $this->getContextMapper()->getContextValues($cached_values['contexts']); - } - -} diff --git a/modules/distro/panelizer/templates/panelizer-view-mode.html.twig b/modules/distro/panelizer/templates/panelizer-view-mode.html.twig deleted file mode 100644 index 415b69190..000000000 --- a/modules/distro/panelizer/templates/panelizer-view-mode.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{# -/** - * @file - * Template for a generic Panelizer view mode. - * - * Available variables: - * - entity: The entity with limited access to object properties and methods. - * - attributes: HTML attributes for the containing element. - * - content: All entity items. - * - entity_url: Direct URL of the current entity. - * - title: The title of the entity. - * - title_element: HTML element to use for the title (defaults to 'h2'). - * - title_attributes: Same as attributes, except applied to the main title - * tag that appears in the template. - * - title_prefix: Additional output populated by modules, intended to be - * displayed in front of the main title tag that appears in the template. - * - title_suffix: Additional output populated by modules, intended to be - * displayed after the main title tag that appears in the template. - * - view_mode: View mode; for example, "teaser" or "full". - * - * @see template_preprocess_panelizer_view_mode() - * - * @ingroup themeable - */ -#} - - {{ title_prefix }} - {% if title %} - <{{ title_element }}{{ title_attributes }}> - {% if entity_url %} - {{ title }} - {% else %} - {{ title }} - {% endif %} - - {% endif %} - {{ title_suffix }} - - - {{ content }} - - diff --git a/modules/distro/panelizer/templates/panelizer-wizard-form.html.twig b/modules/distro/panelizer/templates/panelizer-wizard-form.html.twig deleted file mode 100644 index a6911624e..000000000 --- a/modules/distro/panelizer/templates/panelizer-wizard-form.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{# -/** - * @file - * Default theme implementation for a 'form' element. - * - * Available variables - * - attributes: A list of HTML attributes for the wrapper element. - * - children: The child elements of the form. - * - * @see template_preprocess_form() - * - * @ingroup themeable - */ -#} -
-
- {{ form.wizard_actions }} -
-
-
- {{ form.wizard_tree }} -
-
- {{ form|without('wizard_actions', 'wizard_tree', 'actions') }} -
-
- -
- {{ form.actions }} -
-
diff --git a/modules/distro/panelizer/templates/panelizer-wizard-tree.html.twig b/modules/distro/panelizer/templates/panelizer-wizard-tree.html.twig deleted file mode 100644 index 7d48fcf7a..000000000 --- a/modules/distro/panelizer/templates/panelizer-wizard-tree.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{# -/** - * @file - * Default theme implementation to display wizard tree. - * - * Available variables: - * - step: The current step name. - * - tree: A nested list of menu items. Each menu item contains: - * - title: The menu link title. - * - url: The menu link url, instance of \Drupal\Core\Url - * - children: The menu item child items. - * - step: The name of the step. - * - * @ingroup themeable - */ -#} -{% import _self as panelizer %} - -{# - We call a macro which calls itself to render the full tree. - @see http://twig.sensiolabs.org/doc/tags/macro.html -#} -{{ panelizer.wizard_tree(tree, step, 0) }} - -{% macro wizard_tree(items, step, menu_level) %} - {% import _self as panelizer %} - {% if items %} -
    - {% for item in items %} -
  • - {% if item.url %} - {% if step is same as(item.step) %} - {{ link(item.title, item.url) }} - {% else %} - {{ link(item.title, item.url) }} - {% endif %} - {% else %} - {{ item.title }} - {% endif %} - {% if item.children %} - {{ panelizer.wizard_tree(item.children, step, menu_level + 1) }} - {% endif %} -
  • - {% endfor %} -
- {% endif %} -{% endmacro %} diff --git a/modules/distro/panelizer/tests/fixtures/update/drupal-8.8.panelizer.minimal.php.gz b/modules/distro/panelizer/tests/fixtures/update/drupal-8.8.panelizer.minimal.php.gz deleted file mode 100644 index 0c2220068..000000000 Binary files a/modules/distro/panelizer/tests/fixtures/update/drupal-8.8.panelizer.minimal.php.gz and /dev/null differ diff --git a/modules/distro/panelizer/tests/fixtures/update/drupal-8.panelizer.minimal.php.gz b/modules/distro/panelizer/tests/fixtures/update/drupal-8.panelizer.minimal.php.gz deleted file mode 100644 index 8798cb2f9..000000000 Binary files a/modules/distro/panelizer/tests/fixtures/update/drupal-8.panelizer.minimal.php.gz and /dev/null differ diff --git a/modules/distro/panelizer/tests/modules/panelizer_test/panelizer_test.info.yml b/modules/distro/panelizer/tests/modules/panelizer_test/panelizer_test.info.yml deleted file mode 100644 index bc0c22784..000000000 --- a/modules/distro/panelizer/tests/modules/panelizer_test/panelizer_test.info.yml +++ /dev/null @@ -1,11 +0,0 @@ -type: module -name: Panelizer Test -description: 'Required for Panelizer simpletests only.' -core_version_requirement: ^8.8 || ^9 -dependencies: - - panelizer:panelizer - -# Information added by Drupal.org packaging script on 2022-08-23 -version: '8.x-4.4+2-dev' -project: 'panelizer' -datestamp: 1661286213 diff --git a/modules/distro/panelizer/tests/modules/panelizer_test/src/Plugin/Block/PanelizerTestBlock.php b/modules/distro/panelizer/tests/modules/panelizer_test/src/Plugin/Block/PanelizerTestBlock.php deleted file mode 100644 index 212243fa7..000000000 --- a/modules/distro/panelizer/tests/modules/panelizer_test/src/Plugin/Block/PanelizerTestBlock.php +++ /dev/null @@ -1,26 +0,0 @@ - 'Abracadabra', - ]; - } - -} \ No newline at end of file diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerAddDefaultLinkTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerAddDefaultLinkTest.php deleted file mode 100644 index 2fc35fa2d..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerAddDefaultLinkTest.php +++ /dev/null @@ -1,72 +0,0 @@ -drupalPlaceBlock('local_actions_block', [ - 'region' => 'content', - 'theme' => \Drupal::theme()->getActiveTheme()->getName(), - ]); - - $content_type = 'page'; - - // Log in the user. - $this->loginUser1(); - - // Create the content type. - $this->drupalCreateContentType(['type' => $content_type, 'name' => 'Page']); - - // Panelize the content type. - $this->panelize($content_type); - - // Confirm that the content type is now panelized. - $this->assertSession()->linkExists('Add a new Panelizer default display'); - - // Un-panelize the content type. - $this->unpanelize($content_type); - - // Confirm that the content type is no longer panelized. - $this->assertSession()->linkNotExists('Add a new Panelizer default display'); - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerDefaultsTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerDefaultsTest.php deleted file mode 100644 index 33878cbaa..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerDefaultsTest.php +++ /dev/null @@ -1,91 +0,0 @@ -drupalPlaceBlock('local_actions_block'); - } - - public function test() { - $this->setupContentType(); - $this->loginUser1(); - - // Get all enabled view modes machine names for page. - $view_modes = array_keys(\Drupal::service('entity_display.repository') - ->getViewModeOptionsByBundle('node', 'page')); - foreach ($view_modes as $i => $view_mode_name) { - // Be sure view mode can be panelized. - $this->panelize('page', $view_mode_name); - // Create an additional default layout so we can assert that it's available - // as an option when choosing the layout on the node form. - $panelizer_id = $this->addPanelizerDefault('page', $view_mode_name); - $this->assertDefaultExists('page', $view_mode_name, $panelizer_id); - // The user should only be able to choose the layout if specifically allowed - // to (the panelizer[allow] checkbox in the view display configuration). By - // default, they aren't. - $this->drupalGet('node/add/page'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->fieldValueNotEquals("panelizer['{$i}][default]", ''); - // Allow user to select panelized modes in UI. - $this->panelize('page', $view_mode_name, [ - 'panelizer[custom]' => TRUE, - 'panelizer[allow]' => TRUE, - ]); - $this->drupalGet('node/add/page'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->fieldExists("panelizer[{$i}][default]"); - $this->assertSession()->optionExists("edit-panelizer-{$i}-default", 'default'); - $this->assertSession()->optionExists("edit-panelizer-{$i}-default", $panelizer_id); - // Clean up. - $this->deletePanelizerDefault('page', $view_mode_name, $panelizer_id); - $this->assertDefaultNotExists('page', $view_mode_name, $panelizer_id); - } - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerIpeTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerIpeTest.php deleted file mode 100644 index 731ff6c97..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerIpeTest.php +++ /dev/null @@ -1,383 +0,0 @@ -rebuildAll(); - } - - /** - * The content type that will be tested against. - * - * @string - */ - protected $content_type = 'page'; - - /** - * Create a user with the required permissions. - * - * @param array $perms - * Any additiona permissions that need to be added. - * - * @return Drupal\user\Entity\User - * The user account that was created. - */ - protected function createAdminUser(array $perms = array()) { - $perms += [ - // From system. - 'access administration pages', - - // Content permissions. - 'access content', - 'administer content types', - 'administer nodes', - 'create page content', - 'edit any page content', - 'edit own page content', - - // From Field UI. - 'administer node display', - - // From Panels. - 'access panels in-place editing', - ]; - $this->verbose('
' . print_r($perms, TRUE) . '
'); - return $this->drupalCreateUser($perms); - } - - /** - * Test that the IPE functionality as user 1, which should cover all options. - */ - public function testAdminUser() { - $this->setupContentType($this->content_type); - - // Create a test node. - $node = $this->createTestNode(); - - // Log in as user 1. - $this->loginUser1(); - - // Load the test node. - $this->drupalGet('node/' . $node->id()); - $this->assertSession()->statusCodeEquals(200); - - // Confirm the JSON Drupal settings are appropriate. - $drupalSettings = NULL; - $matches = []; - if (preg_match('@@', $this->getSession()->getPage()->getContent(), $matches)) { - $drupalSettings = Json::decode($matches[1]); - $this->verbose('
' . print_r($drupalSettings, TRUE) . '
'); - } - $this->assertNotNull($drupalSettings); - if (!empty($drupalSettings)) { - $this->assertTrue(isset($drupalSettings['panels_ipe'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['regions'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['layout'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['panels_display'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['unsaved'])); - $this->assertTrue(isset($drupalSettings['panelizer'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_type_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_type_id'], 'node'); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_id'], $node->id()); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['revert'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['save_default'])); - } - } - - /** - * Confirm the 'administer panelizer' permission works. - */ - public function testAdministerPanelizerPermission() { - $this->setupContentType($this->content_type); - - // Create a test node. - $node = $this->createTestNode(); - - // Create a new user with the permissions being tested. - $perms = [ - 'administer panelizer', - ]; - $account = $this->createAdminUser($perms); - $this->drupalLogin($account); - - // Load the test node. - $this->drupalGet('node/' . $node->id()); - $this->assertSession()->statusCodeEquals(200); - - // Confirm the appropriate DOM structures are present for the IPE. - $drupalSettings = NULL; - $matches = []; - if (preg_match('@@', $this->getSession()->getPage()->getContent(), $matches)) { - $drupalSettings = Json::decode($matches[1]); - $this->verbose('
' . print_r($drupalSettings, TRUE) . '
'); - } - $this->assertNotNull($drupalSettings); - if (!empty($drupalSettings)) { - $this->assertTrue(isset($drupalSettings['panels_ipe'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['regions'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['layout'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['panels_display'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['unsaved'])); - $this->assertTrue(isset($drupalSettings['panelizer'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_type_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_type_id'], 'node'); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_id'], $node->id()); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['revert'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['save_default'])); - $this->assertTrue($drupalSettings['panelizer']['user_permission']['revert']); - $this->assertTrue($drupalSettings['panelizer']['user_permission']['save_default']); - } - } - - /** - * @todo Confirm the 'set panelizer default' permission works. - */ - // public function testSetDefault() { - // } - - /** - * @todo Confirm the 'administer panelizer $entity_type_id $bundle defaults' - * permission works. - */ - // public function testAdministerEntityDefaults() { - // } - - /** - * @todo Confirm the 'administer panelizer $entity_type_id $bundle content' - * permission works. - */ - public function testAdministerEntityContentPermission() { - $this->setupContentType($this->content_type); - - // Need the node for the tests below, so create it now. - $node = $this->createTestNode(); - - $perms = [ - 'administer panelizer node page content', - ]; - $drupalSettings = $this->setupPermissionTests($perms, $node); - $this->assertNotNull($drupalSettings); - - // @todo How to tell if the user can change the display or add new items vs - // other tasks? - if (!empty($drupalSettings)) { - $this->assertTrue(isset($drupalSettings['panels_ipe'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['regions'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['layout'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['panels_display'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['unsaved'])); - $this->assertTrue(isset($drupalSettings['panelizer'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_type_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_type_id'], 'node'); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_id'], $node->id()); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['revert'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['save_default'])); - } - } - - /** - * @todo Confirm the 'administer panelizer $entity_type_id $bundle layout' - * permission works. - */ - public function testAdministerEntityLayoutPermission() { - $this->setupContentType($this->content_type); - - // Need the node for the tests below, so create it now. - $node = $this->createTestNode(); - - // Test with just the 'layout' permission - $perms = [ - 'administer panelizer node page layout', - ]; - $drupalSettings = $this->setupPermissionTests($perms, $node); - $this->assertNotNull($drupalSettings); - - if (!empty($drupalSettings)) { - $this->assertFalse(isset($drupalSettings['panels_ipe'])); - $this->assertFalse(isset($drupalSettings['panelizer'])); - } - - // Make sure the user is logged out before doing another pass. - $this->drupalLogout(); - - // Test with the 'revert' and the 'content' permission. - $perms = [ - // The permission to be tested. - 'administer panelizer node page layout', - // This permission has to be enabled for the 'revert' permission to work. - 'administer panelizer node page content', - ]; - $drupalSettings = $this->setupPermissionTests($perms, $node); - $this->assertNotNull($drupalSettings); - - // @todo How to tell if the user can change the layout vs other tasks? - if (!empty($drupalSettings)) { - $this->assertTrue(isset($drupalSettings['panels_ipe'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['regions'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['layout'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['panels_display'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['unsaved'])); - $this->assertTrue(isset($drupalSettings['panelizer'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_type_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_type_id'], 'node'); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_id'], $node->id()); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['revert'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['save_default'])); - $this->assertFalse($drupalSettings['panelizer']['user_permission']['revert']); - $this->assertFalse($drupalSettings['panelizer']['user_permission']['save_default']); - } - } - - /** - * @todo Confirm the 'administer panelizer $entity_type_id $bundle revert' - * permission works. - */ - public function testAdministerEntityRevertPermission() { - $this->setupContentType($this->content_type); - - // Need the node for the tests below, so create it now. - $node = $this->createTestNode(); - - // Test with just the 'revert' permission - $perms = [ - 'administer panelizer node page revert', - ]; - $drupalSettings = $this->setupPermissionTests($perms, $node); - $this->assertNotNull($drupalSettings); - - if (!empty($drupalSettings)) { - $this->assertFalse(isset($drupalSettings['panels_ipe'])); - $this->assertFalse(isset($drupalSettings['panelizer'])); - } - - // Make sure the user is logged out before doing another pass. - $this->drupalLogout(); - - // Test with the 'revert' and the 'content' permission. - $perms = [ - // The permission to be tested. - 'administer panelizer node page revert', - // This permission has to be enabled for the 'revert' permission to work. - 'administer panelizer node page content', - ]; - $drupalSettings = $this->setupPermissionTests($perms, $node); - $this->assertNotNull($drupalSettings); - - if (!empty($drupalSettings)) { - $this->assertTrue(isset($drupalSettings['panels_ipe'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['regions'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['layout'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['panels_display'])); - $this->assertTrue(isset($drupalSettings['panels_ipe']['unsaved'])); - $this->assertTrue(isset($drupalSettings['panelizer'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity'])); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_type_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_type_id'], 'node'); - $this->assertTrue(isset($drupalSettings['panelizer']['entity']['entity_id'])); - $this->assertEquals($drupalSettings['panelizer']['entity']['entity_id'], $node->id()); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['revert'])); - $this->assertTrue(isset($drupalSettings['panelizer']['user_permission']['save_default'])); - $this->assertTrue($drupalSettings['panelizer']['user_permission']['revert']); - $this->assertFalse($drupalSettings['panelizer']['user_permission']['save_default']); - } - } - - /** - * Do the necessary setup work for the individual permissions tests. - * - * @param array $perms - * Any additiona permissions that need to be added. - * @param obj $node - * The node to test against, if none provided one will be generated. - * - * @return array - * The full drupalSettings JSON structure in array format. - */ - protected function setupPermissionTests(array $perms, $node = NULL) { - // Create a new user with the permissions being tested. - $account = $this->createAdminUser($perms); - $this->drupalLogin($account); - - // Make sure there's a test node to work with. - if (empty($node)) { - $node = $this->createTestNode(); - } - - // Load the test node. - $this->drupalGet('node/' . $node->id()); - $this->assertSession()->statusCodeEquals(200); - - // Extract the drupalSettings structure and return it. - $drupalSettings = NULL; - $matches = []; - if (preg_match('@@', $this->getSession()->getPage()->getContent(), $matches)) { - $drupalSettings = Json::decode($matches[1]); - $this->verbose('
' . print_r($drupalSettings, TRUE) . '
'); - } - return $drupalSettings; - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerNodeFunctionalTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerNodeFunctionalTest.php deleted file mode 100644 index 827bd9a95..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerNodeFunctionalTest.php +++ /dev/null @@ -1,168 +0,0 @@ -setupContentType(); - $this->loginUser1(); - $this->panelize('page', NULL, ['panelizer[custom]' => TRUE]); - } - - /** - * Tests the admin interface to set a default layout for a bundle. - */ - public function testWizardUI() { - // Enter the wizard. - $this->drupalGet('admin/structure/panelizer/edit/node__page__default__default'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Wizard Information'); - $this->assertSession()->fieldExists('edit-label'); - - // Contexts step. - $this->clickLink('Contexts'); - $this->assertSession()->pageTextContains('@panelizer.entity_context:entity'); - - // Layout selection step. - $this->clickLink('Layout'); - $this->assertSession()->buttonExists('edit-update-layout'); - - // Content step. Add the Node block to the top region. - $this->clickLink('Content'); - $this->clickLink('Add new block'); - $this->clickLink('Title'); - $edit = [ - 'region' => 'content', - ]; - $this->submitForm($edit, t('Add block')); - $this->assertSession()->statusCodeEquals(200); - - // Finish the wizard. - $this->submitForm([], t('Update and save')); - $this->assertSession()->statusCodeEquals(200); - // Confirm this returned to the main wizard page. - $this->assertSession()->pageTextContains('Wizard Information'); - $this->assertSession()->fieldExists('edit-label'); - - // Return to the Manage Display page, which is where the Cancel button - // currently sends you. That's a UX WTF and should be fixed... - $this->submitForm([], t('Cancel')); - $this->assertSession()->statusCodeEquals(200); - - // Confirm the page is back to the content type settings page. - $this->assertSession()->checkboxChecked('edit-panelizer-custom'); - - // Now change and save the general setting. - $edit = [ - 'panelizer[custom]' => FALSE, - ]; - $this->submitForm($edit, t('Save')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->checkboxNotChecked('edit-panelizer-custom'); - - // Add another block at the Content step and then save changes. - $this->drupalGet('admin/structure/panelizer/edit/node__page__default__default/content'); - $this->assertSession()->statusCodeEquals(200); - $this->clickLink('Add new block'); - $this->clickLink('Body'); - $edit = [ - 'region' => 'content', - ]; - $this->submitForm($edit, t('Add block')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('entity_field:node:body'); - $this->submitForm([], t('Save')); - $this->assertSession()->statusCodeEquals(200); - $this->clickLink('Content'); - $this->assertSession()->pageTextContains('entity_field:node:body'); - - // Check that the Manage Display tab changed now that Panelizer is set up. - // Also, the field display table should be hidden. - $this->assertSession()->responseNotContains('
'); - - // Disable Panelizer for the default display mode. This should bring back - // the field overview table at Manage Display and not display the link to - // edit the default Panelizer layout. - $this->unpanelize('page'); - $this->assertSession()->linkByHrefNotExists('admin/structure/panelizer/edit/node__page__default'); - $this->assertSession()->responseContains('
'); - } - - /** - * Tests rendering a node with Panelizer default. - */ - public function testPanelizerDefault() { - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = $this->container->get('panelizer'); - $displays = $panelizer->getDefaultPanelsDisplays('node', 'page', 'default'); - $display = $displays['default']; - $display->addBlock([ - 'id' => 'panelizer_test', - 'label' => 'Panelizer test', - 'provider' => 'block_content', - 'region' => 'content', - ]); - $panelizer->setDefaultPanelsDisplay('default', 'node', 'page', 'default', $display); - - // Create a node, and check that the IPE is visible on it. - $node = $this->drupalCreateNode(['type' => 'page']); - $out = $this->drupalGet('node/' . $node->id()); - $this->assertSession()->statusCodeEquals(200); - $this->verbose($out); - $elements = $this->xpath('//*[@id="panels-ipe-content"]'); - if (is_array($elements)) { - $this->assertSame(count($elements), 1); - } - else { - $this->fail('Could not parse page content.'); - } - - // Check that the block we added is visible. - $this->assertSession()->pageTextContains('Panelizer test'); - $this->assertSession()->pageTextContains('Abracadabra'); - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerNodeTranslationsTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerNodeTranslationsTest.php deleted file mode 100644 index 2952f2187..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerNodeTranslationsTest.php +++ /dev/null @@ -1,200 +0,0 @@ -loginUser1(); - } - - /** - * The entity type being tested. - * - * @var string - */ - protected $entityTypeId = 'node'; - - /** - * The bundle being tested. - * - * @var string - */ - protected $bundle = 'page'; - - /** - * Tests the admin interface to set a default layout for a bundle. - */ - public function _testWizardUI() { - $this->panelize($this->bundle, NULL, ['panelizer[custom]' => TRUE]); - - // Enter the wizard. - $this->drupalGet("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default__default"); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Wizard Information'); - $this->assertSession()->fieldExists('edit-label'); - - // Contexts step. - $this->clickLink('Contexts'); - $this->assertSession()->pageTextContains('@panelizer.entity_context:entity'); - - // Layout selection step. - $this->clickLink('Layout'); - $this->assertSession()->buttonExists('edit-update-layout'); - - // Content step. Add the Node block to the top region. - // @todo The index will have to change if the install profile is changed. - $this->clickLink('Content', 1); - $this->clickLink('Add new block'); - $this->clickLink('Title'); - $edit = [ - 'region' => 'content', - ]; - $this->submitForm($edit, t('Add block')); - $this->assertSession()->statusCodeEquals(200); - - // Finish the wizard. - $this->submitForm([], t('Update and save')); - $this->assertSession()->statusCodeEquals(200); - // Confirm this returned to the main wizard page. - $this->assertSession()->pageTextContains('Wizard Information'); - $this->assertSession()->fieldExists('edit-label'); - - // Return to the Manage Display page, which is where the Cancel button - // currently sends you. That's a UX WTF and should be fixed... - $this->submitForm([], t('Cancel')); - $this->assertSession()->statusCodeEquals(200); - - // Confirm the page is back to the content type settings page. - $this->assertSession()->checkboxChecked('edit-panelizer-custom'); - - // Now change and save the general setting. - $edit = [ - 'panelizer[custom]' => FALSE, - ]; - $this->submitForm($edit, t('Save')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->checkboxNotChecked('edit-panelizer-custom'); - - // Add another block at the Content step and then save changes. - $this->drupalGet("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default__default/content"); - $this->assertSession()->statusCodeEquals(200); - $this->clickLink('Add new block'); - $this->clickLink('Body'); - $edit = [ - 'region' => 'content', - ]; - $this->submitForm($edit, t('Add block')); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains("entity_field:{$this->entityTypeId}:body"); - $this->submitForm([], t('Save')); - $this->assertSession()->statusCodeEquals(200); - $this->clickLink('Content', 1); - $this->assertSession()->pageTextContains("entity_field:{$this->entityTypeId}:body"); - - // Check that the Manage Display tab changed now that Panelizer is set up. - // Also, the field display table should be hidden. - $this->assertSession()->responseNotContains('
'); - - // Disable Panelizer for the default display mode. This should bring back - // the field overview table at Manage Display and not display the link to - // edit the default Panelizer layout. - $this->unpanelize($this->bundle); - $this->assertSession()->linkByHrefNotExists("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default"); - $this->assertSession()->responseContains('
'); - } - - /** - * Tests rendering a node with Panelizer default. - */ - public function testPanelizerDefault() { - $this->panelize($this->bundle, NULL, ['panelizer[custom]' => TRUE]); - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = $this->container->get('panelizer'); - $displays = $panelizer->getDefaultPanelsDisplays($this->entityTypeId, $this->bundle, 'default'); - $display = $displays['default']; - $display->addBlock([ - 'id' => 'panelizer_test', - 'label' => 'Panelizer test', - 'provider' => 'block_content', - 'region' => 'content', - ]); - $panelizer->setDefaultPanelsDisplay('default', $this->entityTypeId, $this->bundle, 'default', $display); - - // Create a node, and check that the IPE is visible on it. - $node = $this->drupalCreateNode([ - 'type' => $this->bundle, - 'langcode' => [ - [ - 'value' => 'en', - ], - ], - ]); - $out = $this->drupalGet('node/' . $node->id()); - $this->assertSession()->statusCodeEquals(200); - $this->verbose($out); - $elements = $this->xpath('//*[@id="panels-ipe-content"]'); - if (is_array($elements)) { - $this->assertSame(count($elements), 1); - } - else { - $this->fail('Could not parse page content.'); - } - - // Check that the block we added is visible. - $this->assertSession()->pageTextContains('Panelizer test'); - $this->assertSession()->pageTextContains('Abracadabra'); - - // Load the translation page. - $this->clickLink('Translate'); - $this->assertSession()->pageTextContains('English (Original language)'); - $this->assertSession()->pageTextContains('Published'); - $this->assertSession()->pageTextContains('Not translated'); - } - - // @todo Confirm that the different languages of a translated node are loaded properly when using a default display. - // @todo Decide what should happen if a node is translated and has a customized display. - // @todo Confirm loading a referenced block uses the block's correct language. -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerTermFunctionalTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerTermFunctionalTest.php deleted file mode 100644 index 5469be531..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerTermFunctionalTest.php +++ /dev/null @@ -1,127 +0,0 @@ - 'tags', - 'name' => 'Tags', - ])->save(); - - $user = $this->drupalCreateUser([ - 'administer taxonomy', - 'administer taxonomy_term display', - 'edit terms in tags', - 'administer panelizer', - 'access panels in-place editing', - 'administer taxonomy_term fields', - ]); - $this->drupalLogin($user); - - $this->drupalGet('admin/structure/taxonomy/manage/tags/overview/display'); - $edit = [ - 'panelizer[enable]' => TRUE, - 'panelizer[custom]' => TRUE, - ]; - $this->submitForm($edit, t('Save')); - $this->assertSession()->statusCodeEquals(200); - $this->rebuildAll(); - } - - /** - * Tests rendering a taxonomy term with Panelizer default. - */ - public function testPanelizerDefault() { - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - $displays = $panelizer->getDefaultPanelsDisplays('taxonomy_term', 'tags', 'default'); - $display = $displays['default']; - $display->addBlock([ - 'id' => 'panelizer_test', - 'label' => 'Panelizer test', - 'provider' => 'block_content', - 'region' => 'content', - ]); - $panelizer->setDefaultPanelsDisplay('default', 'taxonomy_term', 'tags', 'default', $display); - - // Create a term, and check that the IPE is visible on it. - $term = $this->createTerm(); - - $out = $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertSession()->statusCodeEquals(200); - $this->verbose($out); - $elements = $this->xpath('//*[@id="panels-ipe-content"]'); - if (is_array($elements)) { - $this->assertSame(count($elements), 1); - } - else { - $this->fail('Could not parse page content.'); - } - - // Check that the block we added is visible. - $this->assertSession()->pageTextContains('Panelizer test'); - $this->assertSession()->pageTextContains('Abracadabra'); - } - - /** - * Create a term. - * - * @return Term; - */ - protected function createTerm() { - $settings = [ - 'description' => [['value' => $this->randomMachineName(32)]], - 'name' => $this->randomMachineName(8), - 'vid' => 'tags', - 'uid' => \Drupal::currentUser()->id(), - ]; - $term = Term::create($settings); - $term->save(); - return $term; - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerTestTrait.php b/modules/distro/panelizer/tests/src/Functional/PanelizerTestTrait.php deleted file mode 100644 index a5e47ea6f..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerTestTrait.php +++ /dev/null @@ -1,246 +0,0 @@ -setPassword($password)->save(); - // Support old and new tests. - $account->passRaw = $password; - $account->pass_raw = $password; - $this->drupalLogin($account); - } - - /** - * Prep a content type for use with these tests. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - */ - protected function setupContentType($content_type = 'page') { - // Log in as user 1. - $this->loginUser1(); - - // Create the content type. - $this->drupalCreateContentType(['type' => $content_type, 'name' => 'Page']); - - // Allow each node to have a customized display. - $this->panelize($content_type, NULL, ['panelizer[custom]' => TRUE]); - - // Logout so that a new user can log in. - $this->drupalLogout(); - } - - /** - * Create a test node. - * - * @param string $type - * The entity type to create, defaults to 'page'. - * - * @return object - * An example node. - */ - protected function createTestNode($type = 'page') { - // Create a test node. - return $this->drupalCreateNode([ - 'title' => t('Hello, world!'), - 'type' => $type, - ]); - } - - /** - * Panelizes a node type's default view display. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - * @param string $display - * (optional) The view mode to work on. - * @param array $values - * (optional) Additional form values. - */ - protected function panelize($content_type = 'page', $display = NULL, array $values = []) { - $this->drupalGet("admin/structure/types"); - $this->assertResponse(200); - - $this->drupalGet("admin/structure/types/manage/{$content_type}"); - $this->assertResponse(200); - - $path = "admin/structure/types/manage/{$content_type}/display"; - if (!empty($display)) { - $path .= '/' . $display; - } - $this->drupalGet($path); - $this->assertResponse(200); - - $edit = [ - 'panelizer[enable]' => TRUE, - ] + $values; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); - - \Drupal::service('entity_display.repository')->getFormDisplay('node', $content_type, 'default') - ->setComponent('panelizer', [ - 'type' => 'panelizer', - ]) - ->save(); - } - - /** - * Unpanelizes a node type's default view display. - * - * Panelizer is disabled for the display, but its configuration is retained. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - * @param string $display - * (optional) The view mode to work on. - * @param array $values - * (optional) Additional form values. - */ - protected function unpanelize($content_type = 'page', $display = NULL, array $values = []) { - $this->drupalGet("admin/structure/types/manage/{$content_type}/display/{$display}"); - $this->assertResponse(200); - - $edit = [ - 'panelizer[enable]' => FALSE, - ] + $values; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); - - \Drupal::service('entity_display.repository')->getFormDisplay('node', $content_type, 'default') - ->removeComponent('panelizer') - ->save(); - } - - /** - * - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - */ - protected function addPanelizerDefault($content_type = 'page', $display = 'default') { - $label = $this->getRandomGenerator()->word(16); - $id = strtolower($label); - $default_id = "node__{$content_type}__{$display}__{$id}"; - $options = [ - 'query' => [ - 'js' => 'nojs', - ], - ]; - $path = "admin/structure/types/manage/{$content_type}/display"; - if (!empty($display)) { - $path .= '/' . $display; - } - $this->drupalGet($path); - $this->assertResponse(200); - $this->clickLink('Add a new Panelizer default display'); - - // Step 1: Enter the default's label and ID. - $edit = [ - 'id' => $id, - 'label' => $label, - ]; - $this->drupalPostForm(NULL, $edit, t('Next')); - $this->assertResponse(200); - - // Step 2: Define contexts. - $this->assertUrl("admin/structure/panelizer/add/{$default_id}/contexts", $options); - $this->drupalPostForm(NULL, [], t('Next')); - $this->assertResponse(200); - - // Step 3: Select layout. - $this->assertUrl("admin/structure/panelizer/add/{$default_id}/layout", $options); - $this->drupalPostForm(NULL, [], t('Next')); - $this->assertResponse(200); - - // Step 4: If the layout has settings (new since Drupal 8.8), accept the - // defaults. - $layout_settings_form = $this->getSession() - ->getPage() - ->find('css', '#panels-layout-settings-form'); - if ($layout_settings_form) { - $layout_settings_form->pressButton('Next'); - } - - // Step 5: Select content. - $this->assertUrl("admin/structure/panelizer/add/{$default_id}/content", $options); - $this->drupalPostForm(NULL, [], t('Finish')); - $this->assertResponse(200); - - return $id; - } - - /** - * Deletes a Panelizer default. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - * @param string $display - * (optional) The view mode to work on. - * @param string $id - * (optional) The default ID. - */ - protected function deletePanelizerDefault($content_type = 'page', $display = 'default', $id = 'default') { - $this->drupalGet("admin/structure/panelizer/delete/node__{$content_type}__{$display}__{$id}"); - $this->assertResponse(200); - $this->drupalPostForm(NULL, [], t('Confirm')); - $this->assertResponse(200); - } - - /** - * Asserts that a Panelizer default exists. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - * @param string $display - * (optional) The view mode to work on. - * @param string $id - * (optional) The default ID. - */ - protected function assertDefaultExists($content_type = 'page', $display = 'default', $id = 'default') { - $settings = \Drupal::service('entity_display.repository')->getViewDisplay('node', $content_type, $display) - ->getThirdPartySettings('panelizer'); - - $display_exists = isset($settings['displays'][$id]); - $this->assertTrue($display_exists); - } - - /** - * Asserts that a Panelizer default does not exist. - * - * @param string $content_type - * The content type, i.e. the node bundle ID, to configure; defaults to - * 'page'. - * @param string $display - * (optional) The view mode to work on. - * @param string $id - * The default ID. - */ - protected function assertDefaultNotExists($content_type = 'page', $display = 'default', $id = 'default') { - $settings = \Drupal::service('entity_display.repository')->getViewDisplay('node', $content_type, $display) - ->getThirdPartySettings('panelizer'); - - $display_exists = isset($settings['displays'][$id]); - $this->assertFalse($display_exists); - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/PanelizerUserFunctionalTest.php b/modules/distro/panelizer/tests/src/Functional/PanelizerUserFunctionalTest.php deleted file mode 100644 index 40e57991a..000000000 --- a/modules/distro/panelizer/tests/src/Functional/PanelizerUserFunctionalTest.php +++ /dev/null @@ -1,116 +0,0 @@ -drupalCreateUser([ - // Required for Panelizer. - 'administer panelizer', - 'access panels in-place editing', - // Allow managing user entities. - 'administer users', - // Allow managing user entity settings. - 'administer account settings', - // View access to user profiles. - 'access user profiles', - // Allow managing the user entity fields and display settings. - 'administer user display', - 'administer user fields', - ]); - $this->drupalLogin($user); - - // Enable Panelizer for this entity. - $this->drupalGet('admin/config/people/accounts/display'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'panelizer[enable]' => TRUE, - 'panelizer[custom]' => TRUE, - ]; - $this->submitForm($edit, t('Save')); - $this->assertSession()->statusCodeEquals(200); - - // Reload all caches. - $this->rebuildAll(); - } - - /** - * Tests rendering a user with Panelizer default. - */ - public function testPanelizerDefault() { - /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ - $panelizer = \Drupal::service('panelizer'); - $displays = $panelizer->getDefaultPanelsDisplays('user', 'user', 'default'); - $display = $displays['default']; - $display->addBlock([ - 'id' => 'panelizer_test', - 'label' => 'Panelizer test', - 'provider' => 'block_content', - 'region' => 'content', - ]); - $panelizer->setDefaultPanelsDisplay('default', 'user', 'user', 'default', $display); - - // Create a user, and check that the IPE is visible on it. - $account = $this->drupalCreateUser(); - - // Check the user entity page. - $out = $this->drupalGet('user/' . $account->id()); - $this->assertSession()->statusCodeEquals(200); - $this->verbose($out); - - // Verify that - $elements = $this->xpath('//*[@id="panels-ipe-content"]'); - if (is_array($elements)) { - $this->assertSame(count($elements), 1); - } - else { - $this->fail('Could not parse page content.'); - } - - // Check that the block we added is visible. - $this->assertSession()->pageTextContains('Panelizer test'); - $this->assertSession()->pageTextContains('Abracadabra'); - } - -} diff --git a/modules/distro/panelizer/tests/src/Functional/Update/PanelizerLayoutIDUpdateTest.php b/modules/distro/panelizer/tests/src/Functional/Update/PanelizerLayoutIDUpdateTest.php deleted file mode 100644 index d7fd728f1..000000000 --- a/modules/distro/panelizer/tests/src/Functional/Update/PanelizerLayoutIDUpdateTest.php +++ /dev/null @@ -1,42 +0,0 @@ -databaseDumpFiles = [ - $this->getDrupalRoot() . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', - __DIR__ . '/../../../fixtures/update/drupal-8.8.panelizer.minimal.php.gz', - ]; - } - - /** - * Test updates. - */ - public function testUpdate() { - $this->runUpdates(); - - $this->drupalLogin($this->rootUser); - $this->drupalGet('admin/structure/types/manage/article/display'); - $this->clickLink('Edit', 1); - $this->assertSession()->statusCodeEquals(200); - - $this->drupalGet('node/1'); - $this->assertSession()->statusCodeEquals(200); - - $this->drupalGet('node/2'); - $this->assertSession()->statusCodeEquals(200); - } - -} diff --git a/modules/distro/panelizer/tests/src/FunctionalJavascript/PanelizerIntegrationTest.php b/modules/distro/panelizer/tests/src/FunctionalJavascript/PanelizerIntegrationTest.php deleted file mode 100644 index 2a2b38911..000000000 --- a/modules/distro/panelizer/tests/src/FunctionalJavascript/PanelizerIntegrationTest.php +++ /dev/null @@ -1,175 +0,0 @@ -visitIPERoute(). - */ - protected $window_size = [1024, 768]; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'field_ui', - 'node', - 'panels', - 'panels_ipe', - 'panelizer', - 'system', - ]; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - // Create a user with appropriate permissions to use Panels IPE. - $admin_user = $this->drupalCreateUser([ - 'access content', - 'access panels in-place editing', - 'administer blocks', - 'administer content types', - 'administer nodes', - 'administer node display', - 'administer panelizer', - ]); - $this->drupalLogin($admin_user); - - // Create the "Basic Page" content type. - $this->createContentType([ - 'type' => 'page', - 'name' => 'Basic Page', - ]); - - // Enable Panelizer for the "Basic Page" content type. - $this->drupalGet('admin/structure/types/manage/page/display'); - $this->submitForm(['panelizer[enable]' => 1], t('Save')); - - // Create a new Basic Page. - $this->drupalGet('node/add/page'); - $this->submitForm(['title[0][value]' => 'Test Node'], t('Save')); - - $this->test_route = 'node/1'; - } - - /** - * Tests that the IPE editing session is specific to a user. - */ - public function testUserEditSession() { - $this->visitIPERoute(); - $this->assertSession()->elementExists('css', '.layout--onecol'); - - // Change the layout to lock the IPE. - $this->changeLayout('Columns: 2', 'layout_twocol'); - $this->assertSession()->elementExists('css', '.layout--twocol'); - $this->assertSession()->elementNotExists('css', '.layout--onecol'); - - // Create a second node. - $this->drupalGet('node/add/page'); - $this->submitForm(['title[0][value]' => 'Test Node 2'], t('Save')); - $this->test_route = 'node/2'; - - // Ensure the second node does not use the session of the other node. - $this->visitIPERoute(); - $this->assertSession()->elementExists('css', '.layout--onecol'); - $this->assertSession()->elementNotExists('css', '.layout--twocol'); - } - - /** - * Tests that the IPE is loaded on the current test route. - */ - public function testIPEIsLoaded() { - $this->visitIPERoute(); - - $this->assertIPELoaded(); - } - - /** - * Tests that adding a block with default configuration works. - */ - public function testIPEAddBlock() { - $this->visitIPERoute(); - - $this->addBlock('System', 'system_breadcrumb_block'); - } - - /** - * Tests that changing layout from one (default) to two columns works. - */ - public function testIPEChangeLayout() { - $this->visitIPERoute(); - - // Change the layout to two columns. - $this->changeLayout('Columns: 2', 'layout_twocol'); - $this->waitUntilVisible('.layout--twocol', 10000, 'Layout changed to two column.'); - } - - /** - * Visits the test route and sets an appropriate window size for IPE. - */ - protected function visitIPERoute() { - $this->drupalGet($this->test_route); - - // Set the window size to ensure that IPE elements are visible. - call_user_func_array([$this->getSession(), 'resizeWindow'], $this->window_size); - } - - /** - * {@inheritdoc} - */ - protected function changeLayout($category, $layout_id) { - // Open the "Change Layout" tab. - $this->clickAndWait('[data-tab-id="change_layout"]'); - - // Wait for layouts to be pulled into our collection. - $this->waitUntilNotPresent('.ipe-icon-loading'); - - // Select the target category. - $this->clickAndWait('[data-category="' . $category . '"]'); - - // Select the target layout. - $this->clickAndWait('[data-layout-id="' . $layout_id . '"]'); - - // Wait for the form to load/submit. - $this->waitUntilNotPresent('.ipe-icon-loading'); - - // See if the layout has a settings form (new in Drupal 8.8), and if so, - // submit it without making any changes. This is the only difference - // between this method and the one inherited from PanelsIPETestTrait. - $layout_form = $this->getSession() - ->getPage() - ->find('css', '.panels-ipe-layout-form'); - if ($layout_form) { - $layout_form->pressButton('Change Layout'); - } - - // Wait for the edit tab to become active (happens automatically after - // form submit). - $this->waitUntilVisible('[data-tab-id="edit"].active'); - } - -} diff --git a/modules/distro/panelizer/tests/src/Unit/PanelizerDefaultPanelsStorageTest.php b/modules/distro/panelizer/tests/src/Unit/PanelizerDefaultPanelsStorageTest.php deleted file mode 100644 index 468ff461a..000000000 --- a/modules/distro/panelizer/tests/src/Unit/PanelizerDefaultPanelsStorageTest.php +++ /dev/null @@ -1,271 +0,0 @@ -storage = $this->prophesize(EntityStorageInterface::class); - - $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); - $this->entityTypeManager->getStorage('entity_type_id')->willReturn($this->storage->reveal()); - - $this->panelizer = $this->prophesize(Panelizer::class); - - $this->panelsStorage = $this->getMockBuilder(PanelizerDefaultPanelsStorage::class) - ->setConstructorArgs([ - [], - '', - [], - $this->entityTypeManager->reveal(), - $this->panelizer->reveal(), - ]) - ->setMethods(['getEntityContext']) - ->getMock(); - } - - /** - * @covers ::load - */ - public function testLoadEmptyContext() { - $entity_context = $this->prophesize(AutomaticContext::class); - - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->setContexts([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ])->shouldBeCalled(); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', NULL) - ->willReturn($panels_display->reveal()); - - $this->panelizer - ->getDisplayStaticContexts('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn([]); - - $this->panelsStorage->method('getEntityContext') - ->with($this->equalTo('entity_type_id'), $this->isNull()) - ->willReturn([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ]); - - $this->assertSame($panels_display->reveal(), $this->panelsStorage->load('entity_type_id:bundle:view_mode:default')); - } - - /** - * @covers ::load - */ - public function testLoadWithContextValue() { - $entity_context = $this->prophesize(AutomaticContext::class); - - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->setContexts([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ])->shouldBeCalled(); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', NULL) - ->willReturn($panels_display->reveal()); - - $this->panelizer - ->getDisplayStaticContexts('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn([]); - - $entity = $this->prophesize(EntityInterface::class); - $entity->bundle()->willReturn("bundle"); - $this->storage->load('123')->willReturn($entity->reveal())->shouldBeCalled(); - - $this->panelsStorage->method('getEntityContext') - ->with($this->equalTo('entity_type_id'), $entity->reveal()) - ->willReturn([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ]); - - $this->assertSame($panels_display->reveal(), $this->panelsStorage->load('*entity_type_id:123:view_mode:default')); - } - - /** - * @covers ::load - */ - public function testLoadDoesntExist() { - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', NULL) - ->willReturn(NULL); - - $this->assertSame(NULL, $this->panelsStorage->load('entity_type_id:bundle:view_mode:default')); - } - - /** - * @covers ::load - */ - public function testLoadNoEntity() { - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', NULL) - ->shouldNotBeCalled(); - - $this->assertSame(NULL, $this->panelsStorage->load('*entity_type_id:123:view_mode:default')); - } - - /** - * @covers ::save - */ - public function testSaveSuccessful() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('entity_type_id:bundle:view_mode:default'); - - $this->panelizer->setDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', $panels_display->reveal()) - ->shouldBeCalled(); - - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::save - */ - public function testSaveDoesntExist() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('entity_type_id:bundle:view_mode:default'); - - $this->panelizer->setDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', $panels_display->reveal()) - ->willThrow(new PanelizerException()); - - $this->expectException('Exception'); - $this->expectExceptionMessage("Couldn't find Panelizer default to store Panels display"); - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::save - */ - public function testSaveNoEntity() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('*entity_type_id:123:view_mode:default'); - - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->panelizer->setDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode', $panels_display->reveal()) - ->shouldNotBeCalled(); - - $this->expectException('Exception'); - $this->expectExceptionMessage("Couldn't find Panelizer default to store Panels display"); - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::access - */ - public function testAccessRead() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasDefaultPermission()->shouldNotBeCalled(); - - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'read', $account->reveal())); - } - - /** - * @covers ::access - */ - public function testAccessNotFound() { - $account = $this->prophesize(AccountInterface::class); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn(NULL); - $this->panelizer->hasDefaultPermission()->shouldNotBeCalled(); - - $this->assertEquals(AccessResult::forbidden(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'read', $account->reveal())); - } - - /** - * @covers ::access - */ - public function testAccessNoEntity() { - $account = $this->prophesize(AccountInterface::class); - - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode') - ->shouldNotBeCalled(); - - $this->assertEquals(AccessResult::forbidden(), $this->panelsStorage->access('*entity_type_id:123:view_mode:default', 'read', $account->reveal())); - } - - /** - * @covers ::access - */ - public function testAccessChangeContent() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasDefaultPermission('change content', 'entity_type_id', 'bundle', 'view_mode', 'default', $account->reveal()) - ->willReturn(TRUE); - - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'update', $account->reveal())); - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'delete', $account->reveal())); - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'create', $account->reveal())); - } - - /** - * @covers ::access - */ - public function testAccessChangeLayout() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $this->panelizer->getDefaultPanelsDisplay('default', 'entity_type_id', 'bundle', 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasDefaultPermission('change layout', 'entity_type_id', 'bundle', 'view_mode', 'default', $account->reveal()) - ->willReturn(TRUE); - - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:bundle:view_mode:default', 'change layout', $account->reveal())); - } - -} diff --git a/modules/distro/panelizer/tests/src/Unit/PanelizerEntityViewBuilderTest.php b/modules/distro/panelizer/tests/src/Unit/PanelizerEntityViewBuilderTest.php deleted file mode 100644 index e0f839271..000000000 --- a/modules/distro/panelizer/tests/src/Unit/PanelizerEntityViewBuilderTest.php +++ /dev/null @@ -1,372 +0,0 @@ -entityType = $this->prophesize(EntityTypeInterface::class); - $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); - $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class); - $this->panelizer = $this->prophesize(PanelizerInterface::class); - $this->panelizerManager = $this->prophesize(PanelizerEntityManagerInterface::class); - $this->panelsManager = $this->prophesize(PanelsDisplayManagerInterface::class); - - $this->entityType->id() - ->willReturn('entity_type_id'); - - $this->entityViewBuilder = $this->getMockBuilder(PanelizerEntityViewBuilder::class) - ->setConstructorArgs([ - $this->entityType->reveal(), - $this->entityTypeManager->reveal(), - $this->moduleHandler->reveal(), - $this->panelizer->reveal(), - $this->panelizerManager->reveal(), - $this->panelsManager->reveal() - ]) - ->setMethods(['getFallbackViewBuilder', 'getPanelizerPlugin', 'collectRenderDisplays', 'getEntityContext']) - ->getMock(); - - $this->fallbackViewBuilder = $this->prophesize(EntityViewBuilderInterface::class); - $this->panelizerPlugin = $this->prophesize(PanelizerEntityInterface::class); - - $this->entityViewBuilder->method('getFallbackViewBuilder') - ->willReturn($this->fallbackViewBuilder->reveal()); - $this->entityViewBuilder->method('getPanelizerPlugin') - ->willReturn($this->panelizerPlugin->reveal()); - } - - /** - * Tests buildComponents(). - * - * @covers ::buildComponents - */ - public function testBuildComponents() { - $build = ['random_value' => 123]; - - $entity1 = $this->prophesize(FieldableEntityInterface::class); - $entity1->bundle()->willReturn('abc'); - - $display1 = $this->prophesize(EntityViewDisplayInterface::class); - $display1->getThirdPartySetting('panelizer', 'enable', FALSE) - ->willReturn(TRUE); - - $entity2 = $this->prophesize(FieldableEntityInterface::class); - $entity2->bundle()->willReturn('xyz'); - - $display2 = $this->prophesize(EntityViewDisplayInterface::class); - $display2->getThirdPartySetting('panelizer', 'enable', FALSE) - ->willReturn(FALSE); - - $displays = [ - 'abc' => $display1->reveal(), - 'xyz' => $display2->reveal(), - ]; - - $this->fallbackViewBuilder->buildComponents($build, [234 => $entity2->reveal()], $displays, 'full') - ->shouldBeCalled(); - - $this->moduleHandler->invokeAll('entity_prepare_view', [ - 'entity_type_id', - [123 => $entity1->reveal()], - $displays, - 'full' - ])->shouldBeCalled(); - - $this->entityViewBuilder->buildComponents( - $build, - [ - 123 => $entity1->reveal(), - 234 => $entity2->reveal() - ], - $displays, - 'full' - ); - } - - /** - * Setups up the mock objects for testing view() and viewMultiple(). - * - * @return array - * An associative array with the following keys: - * - entities: Associative array of the mocked entity objects, keyed by the - * id. - * - expected: Associative array of the built render arrays keyed by the - * entity id. - */ - protected function setupView() { - $entity1 = $this->prophesize(FieldableEntityInterface::class); - $entity1->bundle()->willReturn('abc'); - $entity1->getEntityTypeId()->willReturn('entity_type_id'); - $entity1->id()->willReturn(123); - $entity1->getCacheContexts()->willReturn(['context']); - $entity1->getCacheTags()->willReturn(['tag']); - $entity1->getCacheMaxAge()->willReturn(123); - - $display1 = $this->prophesize(EntityViewDisplayInterface::class); - $display1->getThirdPartySetting('panelizer', 'enable', FALSE) - ->willReturn(TRUE); - - $entity2 = $this->prophesize(FieldableEntityInterface::class); - $entity2->bundle()->willReturn('xyz'); - $entity2->getEntityTypeId()->willReturn('entity_type_id'); - - $display2 = $this->prophesize(EntityViewDisplayInterface::class); - $display2->getThirdPartySetting('panelizer', 'enable', FALSE) - ->willReturn(FALSE); - - $this->entityViewBuilder - ->method('collectRenderDisplays') - ->willReturn([ - 'abc' => $display1->reveal(), - 'xyz' => $display2->reveal() - ]); - - $entity_context = $this->prophesize(AutomaticContext::class); - $this->entityViewBuilder->method('getEntityContext') - ->willReturn($entity_context->reveal()); - - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $other_context = $this->prophesize(AutomaticContext::class); - $panels_display->getContexts() - ->willReturn(['other' => $other_context->reveal()]); - $panels_display->setContexts([ - 'other' => $other_context->reveal(), - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ])->shouldBeCalled(); - $panels_display->build()->willReturn(['#markup' => 'Panelized']); - - $this->panelizer - ->getPanelizerSettings('entity_type_id', 'abc', 'full', $display1->reveal()) - ->willReturn([ - 'default' => 'default', - ]); - - $this->panelizer - ->getDisplayStaticContexts('default', 'entity_type_id', 'abc', 'full', $display1->reveal()) - ->willReturn([ - 'other' => $other_context->reveal(), - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ]); - - $this->panelizer->getPanelsDisplay($entity1->reveal(), 'full', $display1->reveal()) - ->willReturn($panels_display->reveal()); - - $panels_display->getCacheContexts()->willReturn([]); - $panels_display->getCacheTags()->willReturn([]); - $panels_display->getCacheMaxAge()->willReturn(-1); - - return [ - 'entities' => [ - 123 => $entity1->reveal(), - 234 => $entity2->reveal(), - ], - 'expected' => [ - 123 => [ - '#theme' => [ - 'panelizer_view_mode__entity_type_id__123', - 'panelizer_view_mode__entity_type_id__abc', - 'panelizer_view_mode__entity_type_id', - 'panelizer_view_mode', - ], - '#panelizer_plugin' => $this->panelizerPlugin->reveal(), - '#panels_display' => $panels_display->reveal(), - '#entity' => $entity1->reveal(), - '#view_mode' => 'full', - '#langcode' => 'pl', - 'content' => [ - '#markup' => 'Panelized', - ], - '#cache' => [ - 'tags' => ['tag'], - 'contexts' => ['context'], - 'max-age' => 123, - ], - ], - 234 => [ - '#markup' => 'Fallback', - ], - ] - ]; - } - - /** - * Tests view(). - * - * @covers ::view - */ - public function testView() { - $data = $this->setupView(); - $entities = $data['entities']; - $expected = $data['expected']; - - $this->fallbackViewBuilder->view($entities[234], 'full', 'pl') - ->willReturn(['#markup' => 'Fallback']); - - $this->assertEquals($expected[123], $this->entityViewBuilder->view($entities[123], 'full', 'pl')); - $this->assertEquals($expected[234], $this->entityViewBuilder->view($entities[234], 'full', 'pl')); - } - - /** - * Tests viewMultiple(). - * - * @covers ::viewMultiple - */ - public function testViewMultiple() { - $data = $this->setupView(); - $entities = $data['entities']; - $expected = $data['expected']; - - $this->fallbackViewBuilder->viewMultiple([234 => $entities[234]], 'full', 'pl') - ->willReturn([234 => ['#markup' => 'Fallback']]); - - $this->assertEquals($expected, $this->entityViewBuilder->viewMultiple($entities, 'full', 'pl')); - } - - /** - * Tests resetCache(). - * - * @covers ::resetCache - */ - public function testResetCache() { - $entities = [ - $this->prophesize(EntityInterface::class)->reveal(), - $this->prophesize(EntityInterface::class)->reveal(), - ]; - $this->fallbackViewBuilder->resetCache($entities)->shouldBeCalled(); - $this->entityViewBuilder->resetCache($entities); - } - - /** - * Tests viewField(). - * - * @covers ::viewField - */ - public function testViewField() { - $items = $this->prophesize(FieldItemListInterface::class)->reveal(); - $display_options = ['abc' => 123]; - $this->fallbackViewBuilder->viewField($items, $display_options) - ->willReturn(['#markup' => 'field']); - $this->assertEquals(['#markup' => 'field'], $this->entityViewBuilder->viewField($items, $display_options)); - } - - /** - * Tests viewFieldItem(). - * - * @covers ::viewFieldItem - */ - public function testViewFieldItem() { - $item = $this->prophesize(FieldItemInterface::class)->reveal(); - $display = ['abc' => 123]; - $this->fallbackViewBuilder->viewFieldItem($item, $display) - ->willReturn(['#markup' => 'item']); - $this->assertEquals(['#markup' => 'item'], $this->entityViewBuilder->viewFieldItem($item, $display)); - } - - /** - * Tests getCacheTags(). - * - * @covers ::getCacheTags - */ - public function testGetCacheTags() { - $this->fallbackViewBuilder->getCacheTags() - ->willReturn(['tag']); - $this->assertEquals(['tag'], $this->entityViewBuilder->getCacheTags()); - } - -} diff --git a/modules/distro/panelizer/tests/src/Unit/PanelizerFieldPanelsStorageTest.php b/modules/distro/panelizer/tests/src/Unit/PanelizerFieldPanelsStorageTest.php deleted file mode 100644 index 440926a2a..000000000 --- a/modules/distro/panelizer/tests/src/Unit/PanelizerFieldPanelsStorageTest.php +++ /dev/null @@ -1,277 +0,0 @@ -storage = $this->prophesize(EntityStorageInterface::class); - - $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); - $this->entityTypeManager->getStorage('entity_type_id')->willReturn($this->storage->reveal()); - - $this->panelizer = $this->prophesize(Panelizer::class); - - $this->panelsStorage = $this->getMockBuilder(PanelizerFieldPanelsStorage::class) - ->setConstructorArgs([ - [], - '', - [], - $this->entityTypeManager->reveal(), - $this->panelizer->reveal(), - ]) - ->setMethods(['getEntityContext']) - ->getMock(); - } - - /** - * @covers ::load - */ - public function testLoad() { - $entity_context = $this->prophesize(AutomaticContext::class); - - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->setContexts([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ])->shouldBeCalled(); - - $entity = $this->prophesize(FieldableEntityInterface::class); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn($panels_display->reveal()); - - $this->storage->load('123')->willReturn($entity->reveal())->shouldBeCalled(); - - $this->panelsStorage->method('getEntityContext') - ->with($this->equalTo('entity_type_id'), $entity->reveal()) - ->willReturn($entity_context->reveal()); - - $this->assertSame($panels_display->reveal(), $this->panelsStorage->load('entity_type_id:123:view_mode')); - } - - /** - * @covers ::load - */ - public function testLoadRevision() { - $entity_context = $this->prophesize(AutomaticContext::class); - - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->setContexts([ - '@panelizer.entity_context:entity' => $entity_context->reveal(), - ])->shouldBeCalled(); - - $entity = $this->prophesize(FieldableEntityInterface::class); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn($panels_display->reveal()); - - $this->storage->loadRevision('456')->willReturn($entity->reveal())->shouldBeCalled(); - - $this->panelsStorage->method('getEntityContext') - ->with($this->equalTo('entity_type_id'), $entity->reveal()) - ->willReturn($entity_context->reveal()); - - $this->assertSame($panels_display->reveal(), $this->panelsStorage->load('entity_type_id:123:view_mode:456')); - } - - /** - * @covers ::load - */ - public function testLoadNoEntity() { - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->panelizer->getPanelsDisplay()->shouldNotBeCalled(); - - $this->assertSame(NULL, $this->panelsStorage->load('entity_type_id:123:view_mode')); - } - - /** - * @covers ::load - */ - public function testLoadNotFound() { - $entity = $this->prophesize(FieldableEntityInterface::class); - - $this->storage->load('123')->willReturn($entity->reveal()); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn(NULL); - - $this->assertSame(NULL, $this->panelsStorage->load('entity_type_id:123:view_mode')); - } - - /** - * @covers ::save - */ - public function testSaveSuccessful() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('entity_type_id:123:view_mode'); - - $entity = $this->prophesize(FieldableEntityInterface::class); - - $this->panelizer->setPanelsDisplay($entity->reveal(), 'view_mode', NULL, $panels_display) - ->shouldBeCalled(); - - $this->storage->load('123')->willReturn($entity->reveal())->shouldBeCalled(); - - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::save - */ - public function testSaveNoEntity() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('entity_type_id:123:view_mode'); - - $this->panelizer->setPanelsDisplay()->shouldNotBeCalled(); - - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->expectException('Exception'); - $this->expectExceptionMessage("Couldn't find entity to store Panels display on"); - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::save - */ - public function testSaveFailed() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $panels_display->getStorageId()->willReturn('entity_type_id:123:view_mode'); - - $entity = $this->prophesize(FieldableEntityInterface::class); - - $this->panelizer->setPanelsDisplay($entity->reveal(), 'view_mode', NULL, $panels_display) - ->willThrow(new PanelizerException("Save failed")); - - $this->storage->load('123')->willReturn($entity->reveal())->shouldBeCalled(); - - $this->expectException('Exception'); - $this->expectExceptionMessage('Save failed'); - $this->panelsStorage->save($panels_display->reveal()); - } - - /** - * @covers ::access - */ - public function testAccessRead() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $entity = $this->prophesize(FieldableEntityInterface::class); - $entity->access('view', $account->reveal(), TRUE) - ->willReturn(AccessResult::allowed()); - - $this->storage->load('123')->willReturn($entity->reveal()); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasEntityPermission()->shouldNotBeCalled(); - - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:123:view_mode', 'read', $account->reveal())); - } - - /** - * @covers ::access - */ - public function testAccessNoEntity() { - $account = $this->prophesize(AccountInterface::class); - - $this->storage->load('123')->willReturn(NULL)->shouldBeCalled(); - - $this->panelizer->getPanelsDisplay()->shouldNotBeCalled(); - - $this->assertEquals(AccessResult::forbidden(), $this->panelsStorage->access('entity_type_id:123:view_mode', 'read', $account->reveal())); - } - - - /** - * @covers ::access - */ - public function testAccessChangeContent() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $entity = $this->prophesize(FieldableEntityInterface::class); - $entity->access('update', $account->reveal(), TRUE) - ->willReturn(AccessResult::allowed()); - - $this->storage->load('123')->willReturn($entity->reveal()); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasEntityPermission('change content', $entity->reveal(), 'view_mode', $account->reveal()) - ->willReturn(TRUE); - - $access = $this->panelsStorage->access('entity_type_id:123:view_mode', 'update', $account->reveal()); - $this->assertEquals(AccessResult::allowed(), $access); - } - - /** - * @covers ::access - */ - public function testAccessChangeLayout() { - $panels_display = $this->prophesize(PanelsDisplayVariant::class); - $account = $this->prophesize(AccountInterface::class); - - $entity = $this->prophesize(FieldableEntityInterface::class); - $entity->access('update', $account->reveal(), TRUE) - ->willReturn(AccessResult::allowed()); - - $this->storage->load('123')->willReturn($entity->reveal()); - - $this->panelizer->getPanelsDisplay($entity->reveal(), 'view_mode') - ->willReturn($panels_display->reveal()); - $this->panelizer->hasEntityPermission('change layout', $entity->reveal(), 'view_mode', $account->reveal()) - ->willReturn(TRUE); - - $this->assertEquals(AccessResult::allowed(), $this->panelsStorage->access('entity_type_id:123:view_mode', 'change layout', $account->reveal())); - } - -} diff --git a/modules/distro/panelizer/tests/src/Unit/PanelizerPatternTest.php b/modules/distro/panelizer/tests/src/Unit/PanelizerPatternTest.php deleted file mode 100644 index dff736801..000000000 --- a/modules/distro/panelizer/tests/src/Unit/PanelizerPatternTest.php +++ /dev/null @@ -1,23 +0,0 @@ -createMock(ContextMapperInterface::class)); - $this->assertTrue(TRUE, 'PanelizerPattern was successfully instantiated.'); - } - -}