Need to override the core file in magento 2












2















How to override this core file because of real path issue



magento230vendormagentoframeworkViewElementTemplateFileValidator.php


Can you suggest how can we override this isPathInDirectoriesfunction in this file










share|improve this question

























  • Have you tried the preference in di.xml?

    – Amit Naraniwal
    Feb 21 at 6:44











  • why do you need to override the method isPathInDirectoriesfunction?

    – Amit Bera
    Feb 21 at 7:55
















2















How to override this core file because of real path issue



magento230vendormagentoframeworkViewElementTemplateFileValidator.php


Can you suggest how can we override this isPathInDirectoriesfunction in this file










share|improve this question

























  • Have you tried the preference in di.xml?

    – Amit Naraniwal
    Feb 21 at 6:44











  • why do you need to override the method isPathInDirectoriesfunction?

    – Amit Bera
    Feb 21 at 7:55














2












2








2








How to override this core file because of real path issue



magento230vendormagentoframeworkViewElementTemplateFileValidator.php


Can you suggest how can we override this isPathInDirectoriesfunction in this file










share|improve this question
















How to override this core file because of real path issue



magento230vendormagentoframeworkViewElementTemplateFileValidator.php


Can you suggest how can we override this isPathInDirectoriesfunction in this file







magento2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 at 7:01









Amit Naraniwal

60239




60239










asked Feb 21 at 6:42









Pradip GarcharPradip Garchar

11614




11614













  • Have you tried the preference in di.xml?

    – Amit Naraniwal
    Feb 21 at 6:44











  • why do you need to override the method isPathInDirectoriesfunction?

    – Amit Bera
    Feb 21 at 7:55



















  • Have you tried the preference in di.xml?

    – Amit Naraniwal
    Feb 21 at 6:44











  • why do you need to override the method isPathInDirectoriesfunction?

    – Amit Bera
    Feb 21 at 7:55

















Have you tried the preference in di.xml?

– Amit Naraniwal
Feb 21 at 6:44





Have you tried the preference in di.xml?

– Amit Naraniwal
Feb 21 at 6:44













why do you need to override the method isPathInDirectoriesfunction?

– Amit Bera
Feb 21 at 7:55





why do you need to override the method isPathInDirectoriesfunction?

– Amit Bera
Feb 21 at 7:55










4 Answers
4






active

oldest

votes


















3














You can override vendormagentoframeworkViewElementTemplateFileValidator.php Using preference



Just add below code to your di.xml file



<preference for="MagentoFrameworkViewElementTemplateFileValidator" type="[VENDOR][EXTENSION]ViewElementTemplateFileValidator" />


now create the class [VENDOR][EXTENSION]ViewElementTemplateFileValidator that extends MagentoFrameworkViewElementTemplateFileValidator



This is done.






share|improve this answer
























  • Thank you so much :)

    – Pradip Garchar
    Feb 21 at 9:28



















1














I have making the two files for that (I have override this core file)



di.xml



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoFrameworkViewElementTemplateFileValidator" type="CustomeCustomelinkBlockValidator" />
</config>


Validator.php file



namespace CustomeCustomelinkBlock;
use MagentoFrameworkFilesystemDriverFile as FileDriver;

//use MagentoFrameworkFilesystemDriverFile;
class Validator extends MagentoFrameworkViewElementTemplateFileValidator
{
protected $filePath;

protected function isPathInDirectories($path, $directories)
{
//my codes
}

}





share|improve this answer































    0














    You can override any of the core file of Magento2 by creating a di.xml file in your module/etc folder.



    Here you can find some useful details as per your requirement.



    Custom Link



    Magento link






    share|improve this answer

































      0














      I think you should use plugin(Interceptors) instead of override whole class.



      please read magento 2 dev docs for more information



      Dev Docs






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "479"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262777%2fneed-to-override-the-core-file-in-magento-2%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3














        You can override vendormagentoframeworkViewElementTemplateFileValidator.php Using preference



        Just add below code to your di.xml file



        <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="[VENDOR][EXTENSION]ViewElementTemplateFileValidator" />


        now create the class [VENDOR][EXTENSION]ViewElementTemplateFileValidator that extends MagentoFrameworkViewElementTemplateFileValidator



        This is done.






        share|improve this answer
























        • Thank you so much :)

          – Pradip Garchar
          Feb 21 at 9:28
















        3














        You can override vendormagentoframeworkViewElementTemplateFileValidator.php Using preference



        Just add below code to your di.xml file



        <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="[VENDOR][EXTENSION]ViewElementTemplateFileValidator" />


        now create the class [VENDOR][EXTENSION]ViewElementTemplateFileValidator that extends MagentoFrameworkViewElementTemplateFileValidator



        This is done.






        share|improve this answer
























        • Thank you so much :)

          – Pradip Garchar
          Feb 21 at 9:28














        3












        3








        3







        You can override vendormagentoframeworkViewElementTemplateFileValidator.php Using preference



        Just add below code to your di.xml file



        <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="[VENDOR][EXTENSION]ViewElementTemplateFileValidator" />


        now create the class [VENDOR][EXTENSION]ViewElementTemplateFileValidator that extends MagentoFrameworkViewElementTemplateFileValidator



        This is done.






        share|improve this answer













        You can override vendormagentoframeworkViewElementTemplateFileValidator.php Using preference



        Just add below code to your di.xml file



        <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="[VENDOR][EXTENSION]ViewElementTemplateFileValidator" />


        now create the class [VENDOR][EXTENSION]ViewElementTemplateFileValidator that extends MagentoFrameworkViewElementTemplateFileValidator



        This is done.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 21 at 7:57









        Mukesh PrajapatiMukesh Prajapati

        1,197415




        1,197415













        • Thank you so much :)

          – Pradip Garchar
          Feb 21 at 9:28



















        • Thank you so much :)

          – Pradip Garchar
          Feb 21 at 9:28

















        Thank you so much :)

        – Pradip Garchar
        Feb 21 at 9:28





        Thank you so much :)

        – Pradip Garchar
        Feb 21 at 9:28













        1














        I have making the two files for that (I have override this core file)



        di.xml



        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="CustomeCustomelinkBlockValidator" />
        </config>


        Validator.php file



        namespace CustomeCustomelinkBlock;
        use MagentoFrameworkFilesystemDriverFile as FileDriver;

        //use MagentoFrameworkFilesystemDriverFile;
        class Validator extends MagentoFrameworkViewElementTemplateFileValidator
        {
        protected $filePath;

        protected function isPathInDirectories($path, $directories)
        {
        //my codes
        }

        }





        share|improve this answer




























          1














          I have making the two files for that (I have override this core file)



          di.xml



          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="CustomeCustomelinkBlockValidator" />
          </config>


          Validator.php file



          namespace CustomeCustomelinkBlock;
          use MagentoFrameworkFilesystemDriverFile as FileDriver;

          //use MagentoFrameworkFilesystemDriverFile;
          class Validator extends MagentoFrameworkViewElementTemplateFileValidator
          {
          protected $filePath;

          protected function isPathInDirectories($path, $directories)
          {
          //my codes
          }

          }





          share|improve this answer


























            1












            1








            1







            I have making the two files for that (I have override this core file)



            di.xml



            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="CustomeCustomelinkBlockValidator" />
            </config>


            Validator.php file



            namespace CustomeCustomelinkBlock;
            use MagentoFrameworkFilesystemDriverFile as FileDriver;

            //use MagentoFrameworkFilesystemDriverFile;
            class Validator extends MagentoFrameworkViewElementTemplateFileValidator
            {
            protected $filePath;

            protected function isPathInDirectories($path, $directories)
            {
            //my codes
            }

            }





            share|improve this answer













            I have making the two files for that (I have override this core file)



            di.xml



            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <preference for="MagentoFrameworkViewElementTemplateFileValidator" type="CustomeCustomelinkBlockValidator" />
            </config>


            Validator.php file



            namespace CustomeCustomelinkBlock;
            use MagentoFrameworkFilesystemDriverFile as FileDriver;

            //use MagentoFrameworkFilesystemDriverFile;
            class Validator extends MagentoFrameworkViewElementTemplateFileValidator
            {
            protected $filePath;

            protected function isPathInDirectories($path, $directories)
            {
            //my codes
            }

            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 21 at 9:33









            Pradip GarcharPradip Garchar

            11614




            11614























                0














                You can override any of the core file of Magento2 by creating a di.xml file in your module/etc folder.



                Here you can find some useful details as per your requirement.



                Custom Link



                Magento link






                share|improve this answer






























                  0














                  You can override any of the core file of Magento2 by creating a di.xml file in your module/etc folder.



                  Here you can find some useful details as per your requirement.



                  Custom Link



                  Magento link






                  share|improve this answer




























                    0












                    0








                    0







                    You can override any of the core file of Magento2 by creating a di.xml file in your module/etc folder.



                    Here you can find some useful details as per your requirement.



                    Custom Link



                    Magento link






                    share|improve this answer















                    You can override any of the core file of Magento2 by creating a di.xml file in your module/etc folder.



                    Here you can find some useful details as per your requirement.



                    Custom Link



                    Magento link







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Feb 21 at 13:51









                    Mukesh Prajapati

                    1,197415




                    1,197415










                    answered Feb 21 at 6:48









                    Mayur JotaniyaMayur Jotaniya

                    9410




                    9410























                        0














                        I think you should use plugin(Interceptors) instead of override whole class.



                        please read magento 2 dev docs for more information



                        Dev Docs






                        share|improve this answer




























                          0














                          I think you should use plugin(Interceptors) instead of override whole class.



                          please read magento 2 dev docs for more information



                          Dev Docs






                          share|improve this answer


























                            0












                            0








                            0







                            I think you should use plugin(Interceptors) instead of override whole class.



                            please read magento 2 dev docs for more information



                            Dev Docs






                            share|improve this answer













                            I think you should use plugin(Interceptors) instead of override whole class.



                            please read magento 2 dev docs for more information



                            Dev Docs







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 25 at 5:08









                            Manish MaheshwariManish Maheshwari

                            11111




                            11111






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Magento Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262777%2fneed-to-override-the-core-file-in-magento-2%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                                How to change which sound is reproduced for terminal bell?

                                Can I use Tabulator js library in my java Spring + Thymeleaf project?